@@ -57,6 +57,55 @@ namespace intel_npu {
57
57
} \
58
58
} while (0 )
59
59
60
+ /* *
61
+ * @brief Macro for registering simple get<> properties which have been previously set. For COMPILED_MODEL
62
+ *
63
+ * This macro is the same as TRY_REGISTER_SIMPLE_PROPERTY with the added functionality that it first verifies
64
+ * whether the option was previously set + forces the property to be public (!!). Basicly it will not register
65
+ * properties which are still on their default values. This is useful for Compiled_model properties to avoid reporting
66
+ * settings which were not set at model compilation. Having properties in compiled_model which report default value can
67
+ * be misleading as those default values might not even haven been used by compiler, or in extreme cornercases be out of
68
+ * sync with the compiler's default values.
69
+ *
70
+ * @param OPT_NAME Class/type of the option (will fetch .name() from it)
71
+ * @param OPT_TYPE Type (template) of the option
72
+ *
73
+ * @details
74
+ * - It first checks if the config has a previusly set value for this key. If there isn't any value set for this key,
75
+ * it will skip registration
76
+ * - Then checks if the option was registered in the global config. Options not present in the global config
77
+ * are not supported in the current configuration and were previously filtered out on plugin level.
78
+ * - The property visibility (public/private) and mutability (RO/RW) are read from the base option descriptor
79
+ * (optionBase) the property will map to
80
+ * - mutability will be automatically forced to READ-ONLY
81
+ * - visibility will be automatically forced to PUBLIC
82
+ * - If the configuration has no entry for the option, it means it was not set, which means it will
83
+ * skip registering it
84
+ * - A simple config.get<OPT_TYPE> lambda function is defined as the property's callback function
85
+ *
86
+ * @note The macro ensures that compiled model properties are marked read-only unless the configuration lacks the
87
+ * specified option type.
88
+ * @note ***** TO BE USED FOR COMPILED_MODEL ONLY ***** It forces the property public!
89
+ */
90
+ #define TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (OPT_NAME, OPT_TYPE ) \
91
+ do { \
92
+ std::string o_name = OPT_NAME.name (); \
93
+ if (!_config.has (o_name)) { \
94
+ break ; \
95
+ } \
96
+ if (_config.isAvailable (o_name)) { \
97
+ bool isPublic = _config.getOpt (o_name).isPublic (); \
98
+ ov::PropertyMutability isMutable = _config.getOpt (o_name).mutability (); \
99
+ if (_pType == PropertiesType::COMPILED_MODEL) { \
100
+ isMutable = ov::PropertyMutability::RO; \
101
+ isPublic = true ; \
102
+ } \
103
+ _properties.emplace (o_name, std::make_tuple (isPublic, isMutable, [](const Config& config) { \
104
+ return config.get <OPT_TYPE>(); \
105
+ })); \
106
+ } \
107
+ } while (0 )
108
+
60
109
/* *
61
110
* @brief Macro for defining otherwise simple get<> properties but which have variable public/private field
62
111
*
@@ -260,6 +309,31 @@ void Properties::registerProperties() {
260
309
// Reset
261
310
_properties.clear ();
262
311
312
+ switch (_pType) {
313
+ case PropertiesType::PLUGIN:
314
+ registerPluginProperties ();
315
+ break ;
316
+ case PropertiesType::COMPILED_MODEL:
317
+ registerCompiledModelProperties ();
318
+ break ;
319
+ default :
320
+ OPENVINO_THROW (" Invalid plugin configuration!" );
321
+ break ;
322
+ }
323
+
324
+ // 2.3. Common metrics (exposed same way by both Plugin and CompiledModel)
325
+ REGISTER_SIMPLE_METRIC (ov::supported_properties, true , _supportedProperties);
326
+
327
+ // 3. Populate supported properties list
328
+ // ========
329
+ for (auto & property : _properties) {
330
+ if (std::get<0 >(property.second )) {
331
+ _supportedProperties.emplace_back (ov::PropertyName (property.first , std::get<1 >(property.second )));
332
+ }
333
+ }
334
+ }
335
+
336
+ void Properties::registerPluginProperties () {
263
337
// 1. Configs
264
338
// ========
265
339
// 1.1 simple configs which only return value
@@ -280,7 +354,6 @@ void Properties::registerProperties() {
280
354
TRY_REGISTER_SIMPLE_PROPERTY (ov::device::id, DEVICE_ID);
281
355
TRY_REGISTER_SIMPLE_PROPERTY (ov::num_streams, NUM_STREAMS);
282
356
TRY_REGISTER_SIMPLE_PROPERTY (ov::weights_path, WEIGHTS_PATH);
283
- TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::model_priority, MODEL_PRIORITY);
284
357
TRY_REGISTER_SIMPLE_PROPERTY (ov::internal::exclusive_async_requests, EXCLUSIVE_ASYNC_REQUESTS);
285
358
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::compilation_mode_params, COMPILATION_MODE_PARAMS);
286
359
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::dma_engines, DMA_ENGINES);
@@ -295,67 +368,48 @@ void Properties::registerProperties() {
295
368
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::backend_compilation_params, BACKEND_COMPILATION_PARAMS);
296
369
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::batch_mode, BATCH_MODE);
297
370
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::turbo, TURBO);
371
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::model_priority, MODEL_PRIORITY);
298
372
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::bypass_umd_caching, BYPASS_UMD_CACHING);
299
373
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::defer_weights_load, DEFER_WEIGHTS_LOAD);
300
374
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::compiler_dynamic_quantization, COMPILER_DYNAMIC_QUANTIZATION);
301
375
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::qdq_optimization, QDQ_OPTIMIZATION);
302
376
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::disable_version_check, DISABLE_VERSION_CHECK);
303
377
TRY_REGISTER_SIMPLE_PROPERTY (ov::intel_npu::batch_compiler_mode_settings, BATCH_COMPILER_MODE_SETTINGS);
304
378
TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);
379
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::workload_type, WORKLOAD_TYPE);
305
380
306
- // 1.2. Special cases
307
- // ==================
308
- if (_pType == PropertiesType::PLUGIN && _metrics != nullptr ) {
309
- // These properties require different handling in plugin vs compiled_model
310
- TRY_REGISTER_SIMPLE_PROPERTY (ov::workload_type, WORKLOAD_TYPE);
311
- // plugin-only
312
- TRY_REGISTER_CUSTOMFUNC_PROPERTY (ov::intel_npu::stepping, STEPPING, [&](const Config& config) {
313
- if (!config.has <STEPPING>()) {
314
- const auto specifiedDeviceName = get_specified_device_name (config);
315
- return static_cast <int64_t >(_metrics->GetSteppingNumber (specifiedDeviceName));
316
- } else {
317
- return config.get <STEPPING>();
318
- }
319
- });
320
- // plugin-only
321
- TRY_REGISTER_CUSTOMFUNC_PROPERTY (ov::intel_npu::max_tiles, MAX_TILES, [&](const Config& config) {
322
- if (!config.has <MAX_TILES>()) {
323
- const auto specifiedDeviceName = get_specified_device_name (config);
324
- return static_cast <int64_t >(_metrics->GetMaxTiles (specifiedDeviceName));
325
- } else {
326
- return config.get <MAX_TILES>();
327
- }
328
- });
381
+ TRY_REGISTER_CUSTOMFUNC_PROPERTY (ov::intel_npu::stepping, STEPPING, [&](const Config& config) {
382
+ if (!config.has <STEPPING>()) {
383
+ const auto specifiedDeviceName = get_specified_device_name (config);
384
+ return static_cast <int64_t >(_metrics->GetSteppingNumber (specifiedDeviceName));
385
+ } else {
386
+ return config.get <STEPPING>();
387
+ }
388
+ });
389
+ TRY_REGISTER_CUSTOMFUNC_PROPERTY (ov::intel_npu::max_tiles, MAX_TILES, [&](const Config& config) {
390
+ if (!config.has <MAX_TILES>()) {
391
+ const auto specifiedDeviceName = get_specified_device_name (config);
392
+ return static_cast <int64_t >(_metrics->GetMaxTiles (specifiedDeviceName));
393
+ } else {
394
+ return config.get <MAX_TILES>();
395
+ }
396
+ });
329
397
330
- TRY_REGISTER_VARPUB_PROPERTY (ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY, [&] {
331
- if (_backend && _backend->getInitStructs ()) {
332
- if (_backend->getInitStructs ()->getCommandQueueDdiTable ().version () >= ZE_MAKE_VERSION (1 , 1 )) {
333
- return true ;
334
- }
398
+ TRY_REGISTER_VARPUB_PROPERTY (ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY, [&] {
399
+ if (_backend && _backend->getInitStructs ()) {
400
+ if (_backend->getInitStructs ()->getCommandQueueDdiTable ().version () >= ZE_MAKE_VERSION (1 , 1 )) {
401
+ return true ;
335
402
}
336
- return false ;
337
- }());
338
- } else if (_pType == PropertiesType::COMPILED_MODEL) {
339
- // These properties require different handling in plugin vs compiled_model
340
- TRY_REGISTER_CUSTOM_PROPERTY (ov::workload_type,
341
- WORKLOAD_TYPE,
342
- true ,
343
- ov::PropertyMutability::RW,
344
- [](const Config& config) {
345
- return config.get <WORKLOAD_TYPE>();
346
- });
347
- // compiled-model only
348
- TRY_REGISTER_VARPUB_PROPERTY (ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY, true );
349
- TRY_REGISTER_SIMPLE_PROPERTY (ov::loaded_from_cache, LOADED_FROM_CACHE);
350
- }
403
+ }
404
+ return false ;
405
+ }());
406
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);
351
407
352
408
// 2. Metrics (static device and enviroment properties)
353
409
// ========
354
410
// REGISTER_SIMPLE_METRIC format: (property, public true/false, return value)
355
411
// REGISTER_CUSTOM_METRIC format: (property, public true/false, return value function)
356
-
357
- // 2.1 Metrics for Plugin-only (or those which need to be handled differently)
358
- if (_pType == PropertiesType::PLUGIN && _metrics != nullptr ) {
412
+ if (_metrics != nullptr ) {
359
413
REGISTER_SIMPLE_METRIC (ov::available_devices, true , _metrics->GetAvailableDevicesNames ());
360
414
REGISTER_SIMPLE_METRIC (ov::device::capabilities, true , _metrics->GetOptimizationCapabilities ());
361
415
REGISTER_SIMPLE_METRIC (
@@ -429,39 +483,90 @@ void Properties::registerProperties() {
429
483
}
430
484
return caching_props;
431
485
});
432
- } else if (_pType == PropertiesType::COMPILED_MODEL) {
433
- // / 2.2 Metrics for CompiledModel-only (or those which need to be handled differently)
434
- REGISTER_CUSTOM_METRIC (ov::model_name, true , [](const Config&) {
435
- // TODO: log an error here as the code shouldn't have gotten here
436
- // this property is implemented in compiled model directly
437
- // this implementation here servers only to publish it in supported_properties
438
- return std::string (" invalid" );
439
- });
440
- REGISTER_SIMPLE_METRIC (ov::optimal_number_of_infer_requests,
441
- true ,
442
- static_cast <uint32_t >(getOptimalNumberOfInferRequestsInParallel (config)));
443
- REGISTER_CUSTOM_METRIC (ov::internal::supported_properties, true , [&](const Config&) {
444
- static const std::vector<ov::PropertyName> supportedProperty{
445
- ov::PropertyName (ov::internal::caching_properties.name (), ov::PropertyMutability::RO)};
446
- return supportedProperty;
447
- });
448
- REGISTER_CUSTOM_METRIC (ov::execution_devices, true , [](const Config&) {
449
- // TODO: log an error here as the code shouldn't have gotten here
450
- // this property is implemented in compiled model directly
451
- // this implementation here servers only to publish it in supported_properties
452
- return std::string (" NPU" );
453
- });
454
486
}
455
- // 2.3. Common metrics (exposed same way by both Plugin and CompiledModel)
456
- REGISTER_SIMPLE_METRIC (ov::supported_properties, true , _supportedProperties);
487
+ }
457
488
458
- // 3. Populate supported properties list
489
+ void Properties::registerCompiledModelProperties () {
490
+ // 1. Configs
459
491
// ========
460
- for (auto & property : _properties) {
461
- if (std::get<0 >(property.second )) {
462
- _supportedProperties.emplace_back (ov::PropertyName (property.first , std::get<1 >(property.second )));
463
- }
464
- }
492
+ // 1.1 simple configs which only return value
493
+ // TRY_REGISTER_SIMPLE_PROPERTY format: (property, config_to_return)
494
+ // TRY_REGISTER_VARPUB_PROPERTY format: (property, config_to_return, dynamic public/private value)
495
+ // TRY_REGISTER_CUSTOMFUNC_PROPERTY format: (property, custom_return_lambda_function)
496
+ // TRY_REGISTER_CUSTOM_PROPERTY format: (property, visibility, mutability, custom_return_lambda_function)
497
+ // FORCE_REGISTER_CUSTOM_PROPERTY format: (property, visibility, mutability, custom_return_lambda_function)
498
+
499
+ // Permanent properties
500
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::enable_cpu_pinning, ENABLE_CPU_PINNING);
501
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::log::level, LOG_LEVEL);
502
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::loaded_from_cache, LOADED_FROM_CACHE);
503
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::model_priority, MODEL_PRIORITY);
504
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::performance_mode, PERFORMANCE_HINT);
505
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::execution_mode, EXECUTION_MODE_HINT);
506
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::hint::num_requests, PERFORMANCE_HINT_NUM_REQUESTS);
507
+ TRY_REGISTER_SIMPLE_PROPERTY (ov::compilation_num_threads, COMPILATION_NUM_THREADS);
508
+
509
+ // Properties we shall only enable if they were set prior-to-compilation
510
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::hint::inference_precision, INFERENCE_PRECISION_HINT);
511
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::hint::model, MODEL_PTR);
512
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::weights_path, WEIGHTS_PATH);
513
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::cache_dir, CACHE_DIR);
514
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::enable_profiling, PERF_COUNT);
515
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::profiling_type, PROFILING_TYPE);
516
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::turbo, TURBO);
517
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::compilation_mode_params, COMPILATION_MODE_PARAMS);
518
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::dma_engines, DMA_ENGINES);
519
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::tiles, TILES);
520
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::compilation_mode, COMPILATION_MODE);
521
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::compiler_type, COMPILER_TYPE);
522
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::platform, PLATFORM);
523
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::dynamic_shape_to_static, DYNAMIC_SHAPE_TO_STATIC);
524
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::backend_compilation_params, BACKEND_COMPILATION_PARAMS);
525
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::bypass_umd_caching, BYPASS_UMD_CACHING);
526
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::defer_weights_load, DEFER_WEIGHTS_LOAD);
527
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::compiler_dynamic_quantization,
528
+ COMPILER_DYNAMIC_QUANTIZATION);
529
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::qdq_optimization, QDQ_OPTIMIZATION);
530
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::disable_version_check, DISABLE_VERSION_CHECK);
531
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::batch_compiler_mode_settings,
532
+ BATCH_COMPILER_MODE_SETTINGS);
533
+ TRY_REGISTER_COMPILEDMODEL_PROPERTY_IFSET (ov::intel_npu::run_inferences_sequentially, RUN_INFERENCES_SEQUENTIALLY);
534
+
535
+ TRY_REGISTER_VARPUB_PROPERTY (ov::intel_npu::batch_mode, BATCH_MODE, false );
536
+
537
+ TRY_REGISTER_CUSTOM_PROPERTY (ov::workload_type,
538
+ WORKLOAD_TYPE,
539
+ true ,
540
+ ov::PropertyMutability::RW,
541
+ [](const Config& config) {
542
+ return config.get <WORKLOAD_TYPE>();
543
+ });
544
+
545
+ // 2. Metrics (static device and enviroment properties)
546
+ // ========
547
+ // REGISTER_SIMPLE_METRIC format: (property, public true/false, return value)
548
+ // REGISTER_CUSTOM_METRIC format: (property, public true/false, return value function)
549
+
550
+ REGISTER_CUSTOM_METRIC (ov::model_name, true , [](const Config&) {
551
+ // TODO: log an error here as the code shouldn't have gotten here
552
+ // this property is implemented in compiled model directly
553
+ // this implementation here servers only to publish it in supported_properties
554
+ return std::string (" invalid" );
555
+ });
556
+ REGISTER_SIMPLE_METRIC (ov::optimal_number_of_infer_requests,
557
+ true ,
558
+ static_cast <uint32_t >(getOptimalNumberOfInferRequestsInParallel (config)));
559
+ REGISTER_CUSTOM_METRIC (ov::internal::supported_properties, false , [&](const Config&) {
560
+ static const std::vector<ov::PropertyName> supportedProperty{
561
+ ov::PropertyName (ov::internal::caching_properties.name (), ov::PropertyMutability::RO)};
562
+ return supportedProperty;
563
+ });
564
+ REGISTER_CUSTOM_METRIC (ov::execution_devices, true , [](const Config&) {
565
+ // TODO: log an error here as the code shouldn't have gotten here
566
+ // this property is implemented in compiled model directly
567
+ // this implementation here servers only to publish it in supported_properties
568
+ return std::string (" NPU" );
569
+ });
465
570
}
466
571
467
572
ov::Any Properties::get_property (const std::string& name, const ov::AnyMap& arguments) const {
0 commit comments