[CAPI] Add ov::hint::execution_mode property (#16466)
This commit is contained in:
parent
cbb25e9483
commit
232c802e07
@ -171,3 +171,17 @@ ov_property_key_enable_profiling;
|
|||||||
*/
|
*/
|
||||||
OPENVINO_C_VAR(const char*)
|
OPENVINO_C_VAR(const char*)
|
||||||
ov_property_key_device_priorities;
|
ov_property_key_device_priorities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read-write property<string> for high-level OpenVINO Execution hint
|
||||||
|
* unlike low-level properties that are individual (per-device), the hints are something that every device accepts
|
||||||
|
* and turns into device-specific settings
|
||||||
|
* Execution mode hint controls preferred optimization targets (performance or accuracy) for given model
|
||||||
|
* It can be set to be below value:
|
||||||
|
* "UNDEFINED" //!< Undefined value, settings may vary from device to device
|
||||||
|
* "PERFORMANCE", //!< Optimize for max performance
|
||||||
|
* "ACCURACY", //!< Optimize for max accuracy
|
||||||
|
* @ingroup ov_property_c_api
|
||||||
|
*/
|
||||||
|
OPENVINO_C_VAR(const char*)
|
||||||
|
ov_property_key_hint_execution_mode;
|
||||||
|
@ -29,3 +29,4 @@ const char* ov_property_key_hint_model_priority = "MODEL_PRIORITY";
|
|||||||
const char* ov_property_key_log_level = "LOG_LEVEL";
|
const char* ov_property_key_log_level = "LOG_LEVEL";
|
||||||
const char* ov_property_key_enable_profiling = "PERF_COUNT";
|
const char* ov_property_key_enable_profiling = "PERF_COUNT";
|
||||||
const char* ov_property_key_device_priorities = "MULTI_DEVICE_PRIORITIES";
|
const char* ov_property_key_device_priorities = "MULTI_DEVICE_PRIORITIES";
|
||||||
|
const char* ov_property_key_hint_execution_mode = "EXECUTION_MODE_HINT";
|
||||||
|
@ -147,6 +147,27 @@ TEST_P(ov_core_test, ov_core_compile_model_with_property) {
|
|||||||
ov_core_free(core);
|
ov_core_free(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(ov_core_test, ov_core_compile_model_with_excution_mode) {
|
||||||
|
std::string device_name = "AUTO";
|
||||||
|
ov_core_t* core = nullptr;
|
||||||
|
OV_EXPECT_OK(ov_core_create(&core));
|
||||||
|
EXPECT_NE(nullptr, core);
|
||||||
|
|
||||||
|
ov_model_t* model = nullptr;
|
||||||
|
OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), nullptr, &model));
|
||||||
|
EXPECT_NE(nullptr, model);
|
||||||
|
|
||||||
|
ov_compiled_model_t* compiled_model = nullptr;
|
||||||
|
const char* key = ov_property_key_hint_execution_mode;
|
||||||
|
const char* value = "PERFORMANCE";
|
||||||
|
OV_EXPECT_OK(ov_core_compile_model(core, model, device_name.c_str(), 2, &compiled_model, key, value));
|
||||||
|
EXPECT_NE(nullptr, compiled_model);
|
||||||
|
|
||||||
|
ov_compiled_model_free(compiled_model);
|
||||||
|
ov_model_free(model);
|
||||||
|
ov_core_free(core);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_P(ov_core_test, ov_core_compile_model_with_property_invalid) {
|
TEST_P(ov_core_test, ov_core_compile_model_with_property_invalid) {
|
||||||
auto device_name = GetParam();
|
auto device_name = GetParam();
|
||||||
ov_core_t* core = nullptr;
|
ov_core_t* core = nullptr;
|
||||||
@ -306,6 +327,30 @@ TEST_P(ov_core_test, ov_core_get_property) {
|
|||||||
ov_core_free(core);
|
ov_core_free(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_P(ov_core_test, ov_core_set_and_get_property_execution_mode) {
|
||||||
|
std::string device_name = "AUTO";
|
||||||
|
ov_core_t* core = nullptr;
|
||||||
|
OV_EXPECT_OK(ov_core_create(&core));
|
||||||
|
EXPECT_NE(nullptr, core);
|
||||||
|
|
||||||
|
const char* key = ov_property_key_hint_execution_mode;
|
||||||
|
char* property_value = nullptr;
|
||||||
|
OV_EXPECT_OK(ov_core_get_property(core, device_name.c_str(), key, &property_value));
|
||||||
|
ov_free(property_value);
|
||||||
|
|
||||||
|
const char* value1 = "ACCURACY";
|
||||||
|
OV_EXPECT_OK(ov_core_set_property(core, device_name.c_str(), key, value1));
|
||||||
|
OV_EXPECT_OK(ov_core_get_property(core, device_name.c_str(), key, &property_value));
|
||||||
|
EXPECT_STREQ(value1, property_value);
|
||||||
|
|
||||||
|
const char* value2 = "PERFORMANCE";
|
||||||
|
OV_EXPECT_OK(ov_core_set_property(core, device_name.c_str(), key, value2));
|
||||||
|
OV_EXPECT_OK(ov_core_get_property(core, device_name.c_str(), key, &property_value));
|
||||||
|
EXPECT_STREQ(value2, property_value);
|
||||||
|
|
||||||
|
ov_core_free(core);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_P(ov_core_test, ov_core_set_get_property_str) {
|
TEST_P(ov_core_test, ov_core_set_get_property_str) {
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported";
|
GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported";
|
||||||
|
Loading…
Reference in New Issue
Block a user