diff --git a/src/bindings/c/include/openvino/c/ov_property.h b/src/bindings/c/include/openvino/c/ov_property.h index b00f72aaeda..54c887435c5 100644 --- a/src/bindings/c/include/openvino/c/ov_property.h +++ b/src/bindings/c/include/openvino/c/ov_property.h @@ -171,3 +171,17 @@ ov_property_key_enable_profiling; */ OPENVINO_C_VAR(const char*) ov_property_key_device_priorities; + +/** + * @brief Read-write property 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; diff --git a/src/bindings/c/src/ov_property.cpp b/src/bindings/c/src/ov_property.cpp index 613d52b376a..2d6c470ae5d 100644 --- a/src/bindings/c/src/ov_property.cpp +++ b/src/bindings/c/src/ov_property.cpp @@ -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_enable_profiling = "PERF_COUNT"; const char* ov_property_key_device_priorities = "MULTI_DEVICE_PRIORITIES"; +const char* ov_property_key_hint_execution_mode = "EXECUTION_MODE_HINT"; diff --git a/src/bindings/c/tests/ov_core_test.cpp b/src/bindings/c/tests/ov_core_test.cpp index 6804504c940..0cb2f29f65e 100644 --- a/src/bindings/c/tests/ov_core_test.cpp +++ b/src/bindings/c/tests/ov_core_test.cpp @@ -147,6 +147,27 @@ TEST_P(ov_core_test, ov_core_compile_model_with_property) { 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) { auto device_name = GetParam(); ov_core_t* core = nullptr; @@ -306,6 +327,30 @@ TEST_P(ov_core_test, ov_core_get_property) { 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) { #ifdef __aarch64__ GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported";