[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:
parent
e978db3132
commit
99eda5b5e1
34
src/bindings/c/include/openvino/c/auto/properties.h
Normal file
34
src/bindings/c/include/openvino/c/auto/properties.h
Normal 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;
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2018-2022 Intel Corporation
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
|
@ -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"
|
||||
|
10
src/bindings/c/src/ov_auto_property.cpp
Normal file
10
src/bindings/c/src/ov_auto_property.cpp
Normal 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";
|
53
src/bindings/c/tests/ov_auto_property_test.cpp
Normal file
53
src/bindings/c/tests/ov_auto_property_test.cpp
Normal 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));
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user