Disable core::set_property() to support ov::device::properties setting (#15175)

* Disable set_property() to support ov::device::properties setting.

* Update benchmark APP to set device properties through compile_model() instead of through set_property().

* Update.

* Update.

* Update some test case including ov::device::properties setting via core.ser_property().

* Since core.set_property() didn't support ov::device::properties setting, just remove the test case to check compile_model() works well if setting ov::device::properties via core.set_property() first.

* Update CompileModel in test name to CompiledModel

Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>

* Add corresponding test case.

Signed-off-by: Wang, Yang <yang4.wang@intel.com>

* Update.

* Update.

* Remove the changes of this commit as this modification has nothing to do
with this PR.

This reverts commit 4f04b9f085.

---------

Signed-off-by: Wang, Yang <yang4.wang@intel.com>
Co-authored-by: Chen Peter <peter.chen@intel.com>
Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
This commit is contained in:
authored and GitHub committed 2023-02-17 10:15:38 +04:00
1 parent 672522492e
commit a088d1ab7d
7 files changed
+49 -76

No files matched your search

+10 -7
View File
@@ -606,11 +606,14 @@ int main(int argc, char* argv[]) {
device_nstreams.erase(device);
}
}
for (auto&& item : config) {
core.set_property(item.first, item.second);
}
auto result = std::find_if(config.begin(), config.end(), [&](const std::pair<std::string, ov::AnyMap>& item) {
if (device_name.find(item.first) == 0)
return true;
return false;
});
ov::AnyMap device_config = {};
if (result != config.end())
device_config = result->second;
size_t batchSize = FLAGS_b;
ov::element::Type type = ov::element::undefined;
std::string topology_name = "";
@@ -642,7 +645,7 @@ int main(int argc, char* argv[]) {
next_step();
slog::info << "Skipping the step for loading model from file" << slog::endl;
auto startTime = Time::now();
compiledModel = core.compile_model(FLAGS_m, device_name);
compiledModel = core.compile_model(FLAGS_m, device_name, device_config);
auto duration_ms = get_duration_ms_till_now(startTime);
slog::info << "Compile model took " << double_to_string(duration_ms) << " ms" << slog::endl;
slog::info << "Original model I/O parameters:" << slog::endl;
@@ -821,7 +824,7 @@ int main(int argc, char* argv[]) {
// --------------------------------------------------------
next_step();
startTime = Time::now();
compiledModel = core.compile_model(model, device_name);
compiledModel = core.compile_model(model, device_name, device_config);
duration_ms = get_duration_ms_till_now(startTime);
slog::info << "Compile model took " << double_to_string(duration_ms) << " ms" << slog::endl;
if (statistics)
+13 -18
View File
@@ -615,24 +615,19 @@ void ov::CoreImpl::set_property(const std::string& device_name, const AnyMap& pr
"set_property is supported only for BATCH itself (without devices). "
"You can configure the devices with set_property before creating the BATCH on top.");
bool isMetaDevice = device_name.find("AUTO") != std::string::npos ||
device_name.find("MULTI") != std::string::npos ||
device_name.find("HETERO") != std::string::npos;
if (!isMetaDevice) {
// unsupport to set ov::device::properties to HW device through this function
auto devices = get_registered_devices();
for (auto&& config : properties) {
auto parsed = parseDeviceNameIntoConfig(config.first);
auto is_secondary_config_for_hw_device =
std::any_of(devices.begin(), devices.end(), [&](const std::string& device) {
return device == parsed._deviceName;
});
OPENVINO_ASSERT(!is_secondary_config_for_hw_device,
"set_property only supported ov::device::propreties for Meta device (AUTO/MULTI/HETERO). "
"You can configure the devices through the compile_model()/loadNetwork() API.");
}
// unsupport to set ov::device::properties to HW device through this function
auto devices = get_registered_devices();
for (auto&& config : properties) {
auto parsed = parseDeviceNameIntoConfig(config.first);
auto is_secondary_config_for_hw_device =
std::any_of(devices.begin(), devices.end(), [&](const std::string& device) {
return device == parsed._deviceName;
});
OPENVINO_ASSERT(!is_secondary_config_for_hw_device,
"set_property do not support ov::device::propreties. "
"You can configure the devices through the compile_model()/loadNetwork() API.");
}
set_property_for_devivce(properties, device_name);
set_property_for_device(properties, device_name);
}
ov::Any ov::CoreImpl::get_property_for_core(const std::string& name) const {
@@ -724,7 +719,7 @@ std::vector<std::string> ov::CoreImpl::get_registered_devices() const {
* @note `deviceName` is not allowed in form of MULTI:CPU, HETERO:GPU,CPU, AUTO:CPU
* just simple forms like CPU, GPU, MULTI, GPU.0, etc
*/
void ov::CoreImpl::set_property_for_devivce(const ov::AnyMap& configMap, const std::string& deviceName) {
void ov::CoreImpl::set_property_for_device(const ov::AnyMap& configMap, const std::string& deviceName) {
auto config = configMap;
if (config.empty()) {
return;
+1 -1
View File
@@ -385,7 +385,7 @@ public:
* @note `deviceName` is not allowed in form of MULTI:CPU, HETERO:GPU,CPU, AUTO:CPU
* just simple forms like CPU, GPU, MULTI, GPU.0, etc
*/
void set_property_for_devivce(const ov::AnyMap& configMap, const std::string& deviceName);
void set_property_for_device(const ov::AnyMap& configMap, const std::string& deviceName);
void add_extension(const std::vector<ov::Extension::Ptr>& extensions);
+2 -2
View File
@@ -269,9 +269,9 @@ void Core::SetConfig(const std::map<std::string, std::string>& config, const std
ov::AnyMap conf = ov::any_copy(config);
if (deviceName.empty()) {
_impl->set_property_for_devivce(conf, std::string());
_impl->set_property_for_device(conf, std::string());
} else {
_impl->set_property_for_devivce(conf, deviceName);
_impl->set_property_for_device(conf, deviceName);
}
}
@@ -326,6 +326,21 @@ TEST(OVClassBasicTest, smoke_SetConfigHeteroThrows) {
OV_ASSERT_NO_THROW(ie.set_property(CommonTestUtils::DEVICE_HETERO, ov::enable_profiling(true)));
}
TEST(OVClassBasicTest, smoke_SetConfigDevicePropertiesThrows) {
ov::Core ie = createCoreWithTemplate();
ASSERT_THROW(ie.set_property("", ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::enable_profiling(true))),
ov::Exception);
ASSERT_THROW(ie.set_property(CommonTestUtils::DEVICE_CPU,
ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::enable_profiling(true))),
ov::Exception);
ASSERT_THROW(ie.set_property(CommonTestUtils::DEVICE_AUTO,
ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::enable_profiling(true))),
ov::Exception);
ASSERT_THROW(ie.set_property(CommonTestUtils::DEVICE_AUTO,
ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::num_streams(4))),
ov::Exception);
}
TEST_P(OVClassBasicTestP, SetConfigHeteroTargetFallbackThrows) {
ov::Core ie = createCoreWithTemplate();
OV_ASSERT_NO_THROW(ie.set_property(CommonTestUtils::DEVICE_HETERO, ov::device::priorities(target_device)));
@@ -360,38 +375,6 @@ TEST(OVClassBasicTest, smoke_SetConfigAutoNoThrows) {
EXPECT_EQ(value, ov::hint::Priority::HIGH);
}
TEST(OVClassBasicTest, smoke_SetConfigWithNoChangeToHWPluginThroughMetaPluginNoThrows) {
ov::Core ie = createCoreWithTemplate();
int32_t preValue = -1, curValue = -1;
ASSERT_NO_THROW(ie.set_property(CommonTestUtils::DEVICE_CPU, {ov::num_streams(20)}));
ASSERT_NO_THROW(curValue = ie.get_property(CommonTestUtils::DEVICE_CPU, ov::num_streams));
EXPECT_EQ(curValue, 20);
std::vector<std::string> metaDevices = {CommonTestUtils::DEVICE_AUTO,
CommonTestUtils::DEVICE_MULTI,
CommonTestUtils::DEVICE_HETERO};
for (auto&& metaDevice : metaDevices) {
ASSERT_NO_THROW(preValue = ie.get_property(CommonTestUtils::DEVICE_CPU, ov::num_streams));
ASSERT_NO_THROW(
ie.set_property(metaDevice, {ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::num_streams(20))}));
ASSERT_NO_THROW(curValue = ie.get_property(CommonTestUtils::DEVICE_CPU, ov::num_streams));
EXPECT_EQ(curValue, preValue);
}
ASSERT_THROW(ie.set_property(CommonTestUtils::DEVICE_CPU,
{ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::num_streams(20))}),
ov::Exception);
ASSERT_THROW(ie.set_property(CommonTestUtils::DEVICE_GPU,
{ov::device::properties(CommonTestUtils::DEVICE_CPU, ov::num_streams(20))}),
ov::Exception);
ASSERT_THROW(ie.set_property(CommonTestUtils::DEVICE_GPU,
{ov::device::properties("GPU.0", ov::num_streams(20))}),
ov::Exception);
ASSERT_THROW(ie.set_property("GPU.0",
{ov::device::properties("GPU.0", ov::num_streams(20))}),
ov::Exception);
}
TEST_P(OVClassSpecificDeviceTestSetConfig, SetConfigSpecificDeviceNoThrow) {
ov::Core ie = createCoreWithTemplate();
@@ -195,23 +195,12 @@ TEST_P(OVSetPropComplieModleGetPropTests, SetPropertyComplieModelGetProperty) {
}
}
TEST_P(OVSetPropComplieModleWihtIncorrectPropTests, SetPropertyComplieModelWithIncorrectProperty) {
OV_ASSERT_NO_THROW(core->set_property(target_device, properties));
ASSERT_THROW(core->compile_model(model, target_device, compileModelProperties), ov::Exception);
}
TEST_P(OVSetPropComplieModleWihtIncorrectPropTests, CanNotCompileModelWithIncorrectProperties) {
ASSERT_THROW(core->compile_model(model, target_device, properties), ov::Exception);
}
TEST_P(OVSetSupportPropComplieModleWithoutConfigTests, SetPropertyComplieModelWithCorrectProperty) {
OV_ASSERT_NO_THROW(core->set_property(target_device, properties));
ASSERT_NO_THROW(core->compile_model(model, target_device, {}));
}
TEST_P(OVSetUnsupportPropComplieModleWithoutConfigTests, SetPropertyComplieModelWithIncorrectProperty) {
OV_ASSERT_NO_THROW(core->set_property(target_device, properties));
ASSERT_THROW(core->compile_model(model, target_device, {}), ov::Exception);
TEST_P(OVSetSupportPropComplieModleWithoutConfigTests, SetPropertyCompiledModelWithCorrectProperty) {
ASSERT_NO_THROW(core->compile_model(model, target_device, properties));
}
std::string OVCompileModelGetExecutionDeviceTests::getTestCaseName(testing::TestParamInfo<OvPropertiesParams> obj) {
@@ -322,7 +322,10 @@ def main():
del device_number_streams[device]
perf_counts = perf_counts
benchmark.set_config(config)
device_config = {}
for device in config:
if benchmark.device.find(device) == 0:
device_config = config[device]
if args.cache_dir:
benchmark.set_cache_dir(args.cache_dir)
@@ -348,7 +351,7 @@ def main():
next_step()
start_time = datetime.utcnow()
compiled_model = benchmark.core.compile_model(args.path_to_model, benchmark.device)
compiled_model = benchmark.core.compile_model(args.path_to_model, benchmark.device, device_config)
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
logger.info(f"Compile model took {duration_ms} ms")
if statistics:
@@ -411,7 +414,7 @@ def main():
next_step()
start_time = datetime.utcnow()
compiled_model = benchmark.core.compile_model(model, benchmark.device)
compiled_model = benchmark.core.compile_model(model, benchmark.device, device_config)
duration_ms = f"{(datetime.utcnow() - start_time).total_seconds() * 1000:.2f}"
logger.info(f"Compile model took {duration_ms} ms")
if statistics: