Skip to content

Commit 4c0fbb2

Browse files
committed
update to use vcl serializer
1 parent 5ab6d0d commit 4c0fbb2

File tree

3 files changed

+67
-32
lines changed

3 files changed

+67
-32
lines changed

src/plugins/intel_npu/src/compiler_adapter/include/vcl_api.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <memory>
88

9+
#include "intel_npu/common/filtered_config.hpp"
910
#include "intel_npu/icompiler.hpp"
1011
#include "npu_driver_compiler.h"
1112
#include "openvino/core/except.hpp"
@@ -79,6 +80,7 @@ vcl_symbols_list();
7980
vcl_weak_symbols_list();
8081
#undef vcl_symbol_statement
8182

83+
bool isUseBaseModelSerializer(const FilteredConfig& config);
8284
std::string supportVclCompiler(int major, int minor);
8385

8486
class VCLCompilerImpl final : public intel_npu::ICompiler {

src/plugins/intel_npu/src/compiler_adapter/src/vcl_api.cpp

Lines changed: 62 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "vcl_api.hpp"
66

7-
#include "intel_npu/common/filtered_config.hpp"
87
#include "intel_npu/config/options.hpp"
98
#include "intel_npu/npu_private_properties.hpp"
109
#include "intel_npu/profiling.hpp"
@@ -125,9 +124,9 @@ VCLCompilerImpl::VCLCompilerImpl() : _logHandle(nullptr), _logger("VCLCompilerIm
125124
_logger.info("Use Lib VCL version to create compiler");
126125
if (VCL_COMPILER_VERSION_MAJOR < _vclVersion.major ||
127126
(VCL_COMPILER_VERSION_MAJOR == _vclVersion.major && VCL_COMPILER_VERSION_MINOR < _vclVersion.minor)) {
128-
_logger.warning("inside supported VCL version is lower than used VCL api:\n plugin was built with VCL %d.%d, "
127+
_logger.warning("inside supported VCL version is lower than loaded VCL api:\n plugin was built with VCL %d.%d, "
129128
"\n but loaded VCL is %d.%d.\n"
130-
"Will downwise to use the latest plugin vcl compiler!!!",
129+
"Will downgrade to use the latest plugin vcl compiler!!!",
131130
VCL_COMPILER_VERSION_MAJOR,
132131
VCL_COMPILER_VERSION_MINOR,
133132
_vclVersion.major,
@@ -196,6 +195,24 @@ struct vcl_allocator_malloc {
196195
}
197196
};
198197

198+
bool isUseBaseModelSerializer(const FilteredConfig& config) {
199+
// user pass use_base_model_serializer config
200+
if (config.isAvailable(ov::intel_npu::use_base_model_serializer.name()) &&
201+
config.has(ov::intel_npu::use_base_model_serializer.name())) {
202+
return config.get<intel_npu::USE_BASE_MODEL_SERIALIZER>();
203+
}
204+
205+
// user pass model_serializer_version config
206+
if (config.isAvailable(ov::intel_npu::model_serializer_version.name()) &&
207+
config.has(ov::intel_npu::use_base_model_serializer.name())) {
208+
return (config.get<intel_npu::MODEL_SERIALIZER_VERSION>() ==
209+
ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY);
210+
}
211+
212+
// vcl serializer method is not set by user, will default to use it.
213+
return false;
214+
}
215+
199216
std::string supportVclCompiler(int major, int minor) {
200217
if (major >= 7 && minor >= 4) {
201218
return "vclAllocatedExecutableCreate2";
@@ -204,12 +221,21 @@ std::string supportVclCompiler(int major, int minor) {
204221
} else {
205222
return "vclExecutableCreate";
206223
}
207-
return "unsupported VCL version";
208224
}
209225

210226
NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const {
211227
_logger.debug("compile start");
212228

229+
/// Check the linked vcl version whether supported in plugin
230+
uint16_t usedMajor = VCL_COMPILER_VERSION_MAJOR, usedMinor = VCL_COMPILER_VERSION_MINOR;
231+
if (static_cast<uint16_t>(VCL_COMPILER_VERSION_MAJOR) == _vclVersion.major) {
232+
usedMinor = std::min(static_cast<uint16_t>(VCL_COMPILER_VERSION_MINOR), _vclVersion.minor);
233+
} else if (static_cast<uint16_t>(VCL_COMPILER_VERSION_MAJOR) > _vclVersion.major) {
234+
usedMajor = _vclVersion.major;
235+
usedMinor = _vclVersion.minor;
236+
}
237+
_logger.debug("the finally used vcl version is %d.%d", usedMajor, usedMinor);
238+
213239
const auto maxOpsetVersion = _compilerProperties.supportedOpsets;
214240
_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);
215241

@@ -223,13 +249,17 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
223249
OPENVINO_THROW("config is not FilteredConfig");
224250
}
225251
FilteredConfig updatedConfig = *filteredConfig;
252+
bool useBaseModelSerializer = true;
253+
254+
// vcl serializer is only support for vcl version >= 7.5
255+
if (usedMajor >= 7 && usedMinor >= 5) {
256+
useBaseModelSerializer = isUseBaseModelSerializer(updatedConfig);
257+
}
258+
if (useBaseModelSerializer) {
259+
_logger.debug("serialize IR is base method");
260+
}
226261
auto serializedIR =
227-
driver_compiler_utils::serializeIR(model,
228-
compilerVersion,
229-
maxOpsetVersion,
230-
updatedConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())
231-
? config.get<USE_BASE_MODEL_SERIALIZER>()
232-
: true);
262+
driver_compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer);
233263

234264
std::string buildFlags;
235265
const bool useIndices = !((compilerVersion.major < 5) || (compilerVersion.major == 5 && compilerVersion.minor < 9));
@@ -246,15 +276,6 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
246276
buildFlags.size()};
247277
_logger.debug("compiler vcl version: %d.%d", _vclVersion.major, _vclVersion.minor);
248278

249-
/// Check the linked vcl version whether supported in plugin
250-
uint16_t usedMajor = VCL_COMPILER_VERSION_MAJOR, usedMinor = VCL_COMPILER_VERSION_MINOR;
251-
if (static_cast<uint16_t>(VCL_COMPILER_VERSION_MAJOR) == _vclVersion.major) {
252-
usedMinor = std::min(static_cast<uint16_t>(VCL_COMPILER_VERSION_MINOR), _vclVersion.minor);
253-
} else if (static_cast<uint16_t>(VCL_COMPILER_VERSION_MAJOR) > _vclVersion.major) {
254-
usedMajor = _vclVersion.major;
255-
usedMinor = _vclVersion.minor;
256-
}
257-
258279
if (usedMajor >= 7 && usedMinor >= 4) {
259280
if (VCL_COMPILER_VERSION_MAJOR < _vclVersion.major) {
260281
_logger.warning("inside supported VCL version is lower than used VCL api:\n plugin was built with VCL "
@@ -289,7 +310,7 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
289310
if (VCL_COMPILER_VERSION_MAJOR < _vclVersion.major) {
290311
_logger.warning("inside supported VCL version is lower than used VCL api:\n plugin was built with VCL "
291312
"%d.%d, \n but loaded VCL is %d.%d.\n"
292-
"Will downwise to form %s to use vclAllocatedExecutableCreate2",
313+
"Will downgrade to form %s to use vclAllocatedExecutableCreate2",
293314
VCL_COMPILER_VERSION_MAJOR,
294315
VCL_COMPILER_VERSION_MINOR,
295316
_vclVersion.major,
@@ -323,7 +344,7 @@ NetworkDescription VCLCompilerImpl::compile(const std::shared_ptr<const ov::Mode
323344
if (VCL_COMPILER_VERSION_MAJOR < _vclVersion.major) {
324345
_logger.warning("inside supported VCL version is lower than used VCL api:\n plugin was built with VCL "
325346
"%d.%d, \n but loaded VCL is %d.%d.\n"
326-
"Will downwise to form %s to use vclAllocatedExecutableCreate2",
347+
"Will downgrade to form %s to use vclAllocatedExecutableCreate2",
327348
VCL_COMPILER_VERSION_MAJOR,
328349
VCL_COMPILER_VERSION_MINOR,
329350
_vclVersion.major,
@@ -416,6 +437,17 @@ uint32_t VCLCompilerImpl::get_version() const {
416437

417438
ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model>& model, const Config& config) const {
418439
_logger.debug("query start");
440+
441+
/// Check the linked vcl version whether supported in plugin
442+
uint16_t usedMajor = VCL_COMPILER_VERSION_MAJOR, usedMinor = VCL_COMPILER_VERSION_MINOR;
443+
if (static_cast<uint16_t>(VCL_COMPILER_VERSION_MAJOR) == _vclVersion.major) {
444+
usedMinor = std::min(static_cast<uint16_t>(VCL_COMPILER_VERSION_MINOR), _vclVersion.minor);
445+
} else if (static_cast<uint16_t>(VCL_COMPILER_VERSION_MAJOR) > _vclVersion.major) {
446+
usedMajor = _vclVersion.major;
447+
usedMinor = _vclVersion.minor;
448+
}
449+
_logger.debug("the finally used vcl version is %d.%d", usedMajor, usedMinor);
450+
419451
const auto maxOpsetVersion = _compilerProperties.supportedOpsets;
420452
_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);
421453

@@ -428,14 +460,16 @@ ov::SupportedOpsMap VCLCompilerImpl::query(const std::shared_ptr<const ov::Model
428460
OPENVINO_THROW("config is not FilteredConfig");
429461
}
430462
FilteredConfig updatedConfig = *filteredConfig;
431-
463+
bool useBaseModelSerializer = true;
464+
// vcl serializer is only support for vcl version >= 7.5
465+
if (usedMajor >= 7 && usedMinor >= 5) {
466+
useBaseModelSerializer = isUseBaseModelSerializer(updatedConfig);
467+
}
468+
if (useBaseModelSerializer) {
469+
_logger.debug("serialize IR is base method");
470+
}
432471
auto serializedIR =
433-
driver_compiler_utils::serializeIR(model,
434-
compilerVersion,
435-
maxOpsetVersion,
436-
updatedConfig.isAvailable(ov::intel_npu::use_base_model_serializer.name())
437-
? config.get<USE_BASE_MODEL_SERIALIZER>()
438-
: true);
472+
driver_compiler_utils::serializeIR(model, compilerVersion, maxOpsetVersion, useBaseModelSerializer);
439473

440474
std::string buildFlags;
441475
buildFlags += driver_compiler_utils::serializeConfig(config, compilerVersion);

src/plugins/intel_npu/src/plugin/src/plugin.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void checkUpdateforSpecialPlatform(const FilteredConfig& base_conf,
176176

177177
// If user set compilerType in config, will not update by device
178178
auto it = propertiesMap.find(std::string(COMPILER_TYPE::key()));
179-
if(it != propertiesMap.end()) {
179+
if (it != propertiesMap.end()) {
180180
return;
181181
}
182182

@@ -203,9 +203,8 @@ void checkUpdateforSpecialPlatform(const FilteredConfig& base_conf,
203203
}
204204

205205
if (base_conf.get<COMPILER_TYPE>() != ov::intel_npu::CompilerType::DRIVER) {
206-
log.warning(
207-
"Platform '3720' is selected, but the used compiler_type is not set to 'DRIVER'. Forcely use the "
208-
"compiler_type to 'DRIVER'. Maybe cause the compilerType inconsistency issues.");
206+
log.warning("Platform '3720' is selected, but the used compiler_type is not set to 'DRIVER'. Forcely use the "
207+
"compiler_type to 'DRIVER'. Maybe cause the compilerType inconsistency issues.");
209208
}
210209

211210
// To avoid compilerType inconsistency issues, only set DRIVER if compiler_type is not set by user

0 commit comments

Comments
 (0)