[PYTHON][CAPI][AUTO] Add ENABLE_STARTUP_FALLBACK and ENABLE_RUNTIME_FALLBACK proper… (#16436)

* [AUTO] Add ENABLE_STARTUP_FALLBACK and ENABLE_RUNTIME_FALLBACK properties to Python API

* Add DEVICE_BIND_BUFFER property

* Add AUTO properties to C API

* Update test case && Update AUTO properties in PYTHON API

* Create dedicated files for auto plugin

* Update header files

* Update test case

* Modify code style

* Update variable name

* Add test case for invalid input value
This commit is contained in:
Wang Wangwang 2023-04-03 11:56:48 +08:00 committed by GitHub
parent e978db3132
commit 99eda5b5e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1,34 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
/**
* @brief This is a specified header file for auto plugin's properties
*
* @file properties.h
*/
#pragma once
#include "openvino/c/ov_common.h"
/**
* @brief Read-write property<string> for setting that enables performance improvement by binding
* buffer to hw infer request
* @ingroup ov_property_c_api
*/
OPENVINO_C_VAR(const char*)
ov_property_key_intel_auto_device_bind_buffer;
/**
* @brief Read-write property<string> to enable/disable CPU as accelerator (or helper device) at the beginning
* @ingroup ov_property_c_api
*/
OPENVINO_C_VAR(const char*)
ov_property_key_intel_auto_enable_startup_fallback;
/**
* @brief Read-write property<string> to enable/disable runtime fallback to other devices when infer fails
* @ingroup ov_property_c_api
*/
OPENVINO_C_VAR(const char*)
ov_property_key_intel_auto_enable_runtime_fallback;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2018-2022 Intel Corporation
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

View File

@ -15,6 +15,7 @@
**/
#pragma once
#include "openvino/c/auto/properties.h"
#include "openvino/c/ov_common.h"
#include "openvino/c/ov_compiled_model.h"
#include "openvino/c/ov_core.h"

View File

@ -0,0 +1,10 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/c/auto/properties.h"
// Read-write property key
const char* ov_property_key_intel_auto_device_bind_buffer = "DEVICE_BIND_BUFFER";
const char* ov_property_key_intel_auto_enable_startup_fallback = "ENABLE_STARTUP_FALLBACK";
const char* ov_property_key_intel_auto_enable_runtime_fallback = "ENABLE_RUNTIME_FALLBACK";

View File

@ -0,0 +1,53 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "ov_test.hpp"
using test_params = std::tuple<std::string, const char*, const char*, bool>;
class ov_auto_plugin_test : public ::testing::TestWithParam<test_params> {
public:
std::string device_name;
const char* auto_property;
const char* property_value;
bool invalid_value;
public:
void SetUp() override {
std::tie(device_name, auto_property, property_value, invalid_value) = GetParam();
}
};
TEST_P(ov_auto_plugin_test, ov_core_auto_set_and_get_property_bool) {
ov_core_t* core = nullptr;
OV_EXPECT_OK(ov_core_create(&core));
EXPECT_NE(nullptr, core);
OV_EXPECT_OK(ov_core_set_property(core, device_name.c_str(), auto_property, property_value));
char* ret = nullptr;
if (invalid_value) {
OV_EXPECT_NOT_OK(ov_core_get_property(core, device_name.c_str(), auto_property, &ret));
EXPECT_STRNE(property_value, ret);
} else {
OV_EXPECT_OK(ov_core_get_property(core, device_name.c_str(), auto_property, &ret));
EXPECT_STREQ(property_value, ret);
}
ov_free(ret);
ov_core_free(core);
}
const std::vector<test_params> test_property_config = {
test_params{"AUTO", ov_property_key_intel_auto_device_bind_buffer, "YES", false},
test_params{"AUTO", ov_property_key_intel_auto_device_bind_buffer, "NO", false},
test_params{"AUTO", ov_property_key_intel_auto_device_bind_buffer, "TEST", true},
test_params{"AUTO", ov_property_key_intel_auto_enable_startup_fallback, "YES", false},
test_params{"AUTO", ov_property_key_intel_auto_enable_startup_fallback, "NO", false},
test_params{"AUTO", ov_property_key_intel_auto_enable_startup_fallback, "TEST", true},
test_params{"AUTO", ov_property_key_intel_auto_enable_runtime_fallback, "YES", false},
test_params{"AUTO", ov_property_key_intel_auto_enable_runtime_fallback, "NO", false},
test_params{"AUTO", ov_property_key_intel_auto_enable_runtime_fallback, "TEST", true},
};
INSTANTIATE_TEST_SUITE_P(ov_auto_plugin_test_properties,
ov_auto_plugin_test,
::testing::ValuesIn(test_property_config));

View File

@ -271,4 +271,13 @@ void regmodule_properties(py::module m) {
m_streams.def("num", [](const int32_t value) {
return ov::streams::num(ov::streams::Num(value));
});
// Submodule auto
py::module m_intel_auto =
m_properties.def_submodule("intel_auto",
"openvino.runtime.properties.intel_auto submodule that simulates ov::intel_auto");
wrap_property_RW(m_intel_auto, ov::intel_auto::device_bind_buffer, "device_bind_buffer");
wrap_property_RW(m_intel_auto, ov::intel_auto::enable_startup_fallback, "enable_startup_fallback");
wrap_property_RW(m_intel_auto, ov::intel_auto::enable_runtime_fallback, "enable_runtime_fallback");
}

View File

@ -10,6 +10,7 @@
#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/intel_cpu/properties.hpp"
#include "openvino/runtime/intel_gpu/properties.hpp"
#include "openvino/runtime/auto/properties.hpp"
#include "pyopenvino/core/properties/properties.hpp"
namespace py = pybind11;

View File

@ -268,6 +268,36 @@ def test_properties_ro(ov_property_ro, expected_value):
(2.0, 2.0),
),
),
(
properties.intel_auto.device_bind_buffer,
"DEVICE_BIND_BUFFER",
(
(True, True),
(False, False),
(1, True),
(0, False),
),
),
(
properties.intel_auto.enable_startup_fallback,
"ENABLE_STARTUP_FALLBACK",
(
(True, True),
(False, False),
(1, True),
(0, False),
),
),
(
properties.intel_auto.enable_runtime_fallback,
"ENABLE_RUNTIME_FALLBACK",
(
(True, True),
(False, False),
(1, True),
(0, False),
),
),
(properties.device.id, "DEVICE_ID", (("0", "0"),)),
(
properties.log.level,