Skip to content

Commit 992d18c

Browse files
sbutnaripereanub
andauthored
[NPU] Fix: Caching Properties in offline compilation (#33909)
### Details: - Fixing offline compilation usecases, where the driver does not exist some properties will throw. - Added try catch blocks to max_tiles and stepping properties ### Tickets: - C180345 --------- Signed-off-by: Sorin Butnariu <sorin.butnariu@intel.com> Co-authored-by: Bogdan Pereanu <bogdan.pereanu@intel.com>
1 parent 0c35c46 commit 992d18c

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

src/plugins/intel_npu/src/plugin/include/properties.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Properties final {
6767
std::map<std::string, std::tuple<bool, ov::PropertyMutability, std::function<ov::Any(const Config&)>>> _properties;
6868
std::vector<ov::PropertyName> _supportedProperties;
6969

70-
// internal registration functions basd on client object
70+
// internal registration functions based on client object
7171
void registerPluginProperties();
7272
void registerCompiledModelProperties();
7373

@@ -89,6 +89,7 @@ class Properties final {
8989
ov::intel_npu::dynamic_shape_to_static.name(),
9090
ov::intel_npu::enable_strides_for.name(),
9191
ov::intel_npu::max_tiles.name(),
92+
ov::intel_npu::stepping.name(),
9293
ov::intel_npu::tiles.name(),
9394
ov::intel_npu::turbo.name(),
9495
ov::intel_npu::qdq_optimization.name(),

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,19 +393,27 @@ void Properties::registerPluginProperties() {
393393

394394
TRY_REGISTER_CUSTOMFUNC_PROPERTY(ov::intel_npu::stepping, STEPPING, [&](const Config& config) {
395395
if (!config.has<STEPPING>()) {
396-
const auto specifiedDeviceName = get_specified_device_name(config);
397-
return static_cast<int64_t>(_metrics->GetSteppingNumber(specifiedDeviceName));
398-
} else {
399-
return config.get<STEPPING>();
396+
try {
397+
const auto specifiedDeviceName = get_specified_device_name(config);
398+
return static_cast<int64_t>(_metrics->GetSteppingNumber(specifiedDeviceName));
399+
} catch (...) {
400+
Logger("Properties", ov::log::Level::WARNING)
401+
.warning("Metrics GetSteppingNumber failed to get value from device.");
402+
}
400403
}
404+
return config.get<STEPPING>();
401405
});
402406
TRY_REGISTER_CUSTOMFUNC_PROPERTY(ov::intel_npu::max_tiles, MAX_TILES, [&](const Config& config) {
403407
if (!config.has<MAX_TILES>()) {
404-
const auto specifiedDeviceName = get_specified_device_name(config);
405-
return static_cast<int64_t>(_metrics->GetMaxTiles(specifiedDeviceName));
406-
} else {
407-
return config.get<MAX_TILES>();
408+
try {
409+
const auto specifiedDeviceName = get_specified_device_name(config);
410+
return static_cast<int64_t>(_metrics->GetMaxTiles(specifiedDeviceName));
411+
} catch (...) {
412+
Logger("Properties", ov::log::Level::WARNING)
413+
.warning("Metrics GetMaxTiles failed to get value from device.");
414+
}
408415
}
416+
return config.get<MAX_TILES>();
409417
});
410418

411419
TRY_REGISTER_VARPUB_PROPERTY(ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY, [&] {

src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const std::vector<ov::AnyMap> cachingProperties = {
125125
{ov::hint::execution_mode(ov::hint::ExecutionMode::PERFORMANCE)},
126126
{ov::hint::inference_precision(ov::element::i8)},
127127
{ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)},
128-
{ov::intel_npu::batch_compiler_mode_settings("NPU_BATCH_SIZE=4")},
128+
{ov::intel_npu::batch_compiler_mode_settings("batch-compile-method=unroll")},
129129
{ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)},
130130
{ov::intel_npu::compilation_mode("ReferenceSW")},
131131
{ov::intel_npu::compilation_mode_params("dummy-op-replacement=true")},
@@ -134,11 +134,11 @@ const std::vector<ov::AnyMap> cachingProperties = {
134134
{ov::intel_npu::dma_engines(1)},
135135
{ov::intel_npu::dynamic_shape_to_static("true")},
136136
{ov::intel_npu::max_tiles(64)},
137+
{ov::intel_npu::stepping(1)},
137138
{ov::intel_npu::tiles(2)},
138139
{ov::intel_npu::turbo(true)},
139140
{ov::intel_npu::qdq_optimization(true)},
140-
{ov::intel_npu::qdq_optimization_aggressive(true)}
141-
};
141+
{ov::intel_npu::qdq_optimization_aggressive(true)}};
142142

143143
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CachingSupportCase_NPU_Check_Config,
144144
CompileModelLoadFromCacheTest,

0 commit comments

Comments
 (0)