add value verification to check if device priorities value is available (#12069)
* add value verificatioin for the key ov::device::priorities and corresponding test case. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Retrieve the device name via the DeviceIDParser rather than via the priorities directly. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Add logic to support devices like CPU(x),GPU(x). Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Add 'mock' as a available device name when checking if ov::device::priorities is correct. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update format. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * do not check if priorities is available when value of priorigies is empty. Signed-off-by: Wang, Yang <yang4.wang@intel.com> * Update. Signed-off-by: Wang, Yang <yang4.wang@intel.com> Signed-off-by: Wang, Yang <yang4.wang@intel.com> Co-authored-by: Chen Peter <peter.chen@intel.com>
This commit is contained in:
parent
c35af4c0d0
commit
1c6f460458
@ -83,16 +83,7 @@ std::vector<DeviceInformation> MultiDeviceInferencePlugin::ParseMetaDevices(cons
|
||||
std::vector<DeviceInformation> metaDevices;
|
||||
|
||||
// parsing the string and splitting to tokens
|
||||
std::vector<std::string> devicesWithRequests;
|
||||
// parsing the string and splitting the comma-separated tokens
|
||||
std::string::size_type i = 0;
|
||||
std::string::size_type idelimeter;
|
||||
while ((idelimeter = priorities.find(',', i)) != std::string::npos) {
|
||||
devicesWithRequests.push_back(priorities.substr(i, idelimeter - i));
|
||||
i = idelimeter + 1;
|
||||
}
|
||||
// last token in the string (which has no comma after that)
|
||||
devicesWithRequests.push_back(priorities.substr(i, priorities.length() - i));
|
||||
std::vector<std::string> devicesWithRequests = _pluginConfig.ParsePrioritiesDevices(priorities);
|
||||
|
||||
auto getDeviceConfig = [&] (const DeviceName & deviceWithID) {
|
||||
DeviceIDParser deviceParser(deviceWithID);
|
||||
@ -764,17 +755,9 @@ std::string MultiDeviceInferencePlugin::GetDeviceList(const std::map<std::string
|
||||
allDevices += ((device == deviceList[deviceList.size()-1]) ? "" : ",");
|
||||
}
|
||||
} else {
|
||||
// parsing the string and splitting the comma-separated tokens
|
||||
std::string::size_type i = 0;
|
||||
std::string::size_type idelimeter;
|
||||
std::vector<std::string> deviceVec;
|
||||
auto priorities = deviceListConfig->second;
|
||||
while ((idelimeter = priorities.find(',', i)) != std::string::npos) {
|
||||
deviceVec.push_back(priorities.substr(i, idelimeter - i));
|
||||
i = idelimeter + 1;
|
||||
}
|
||||
// last token in the string (which has no comma after that)
|
||||
deviceVec.push_back(priorities.substr(i, priorities.length() - i));
|
||||
// parsing the string and splitting the comma-separated tokens
|
||||
std::vector<std::string> deviceVec = _pluginConfig.ParsePrioritiesDevices(priorities);
|
||||
std::vector<std::string> devicesToBeDeleted;
|
||||
auto updateDeviceVec = [&](const std::string& delPattern = "") {
|
||||
auto iter = deviceVec.begin();
|
||||
|
@ -92,6 +92,8 @@ struct PluginConfig {
|
||||
IE_THROW() << "Unsupported config value: " << kvp.second
|
||||
<< " for key: " << kvp.first;
|
||||
} else if (kvp.first == ov::device::priorities.name()) {
|
||||
if (!kvp.second.empty())
|
||||
ParsePrioritiesDevices(kvp.second);
|
||||
_devicePriority = kvp.second;
|
||||
} else if (std::find(perf_hints_configs.begin(), perf_hints_configs.end(), kvp.first) != perf_hints_configs.end()) {
|
||||
_perfHintsConfig.SetConfig(kvp.first, kvp.second);
|
||||
@ -111,6 +113,42 @@ struct PluginConfig {
|
||||
_keyConfigMap.clear();
|
||||
adjustKeyMapValues();
|
||||
}
|
||||
std::vector<std::string> ParsePrioritiesDevices(const std::string& priorities, const char separator = ',') const {
|
||||
std::vector<std::string> devices;
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type endpos = 0;
|
||||
auto isAvailableDevice = [&](std::string& deviceName) -> bool {
|
||||
if (deviceName.empty())
|
||||
return false;
|
||||
auto realDevName = deviceName[0] != '-' ? deviceName : deviceName.substr(1);
|
||||
if (realDevName.empty()) {
|
||||
return false;
|
||||
}
|
||||
realDevName = DeviceIDParser(realDevName).getDeviceName();
|
||||
std::string::size_type realEndPos = 0;
|
||||
if ((realEndPos = realDevName.find('(')) != std::string::npos) {
|
||||
realDevName = realDevName.substr(0, realEndPos);
|
||||
}
|
||||
if (_availableDevices.end() == std::find(_availableDevices.begin(), _availableDevices.end(), realDevName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
while ((endpos = priorities.find(separator, pos)) != std::string::npos) {
|
||||
auto subStr = priorities.substr(pos, endpos - pos);
|
||||
if (!isAvailableDevice(subStr)) {
|
||||
IE_THROW() << "Unavailable device name: " << subStr;
|
||||
}
|
||||
devices.push_back(subStr);
|
||||
pos = endpos + 1;
|
||||
}
|
||||
auto subStr = priorities.substr(pos, priorities.length() - pos);
|
||||
if (!isAvailableDevice(subStr)) {
|
||||
IE_THROW() << "Unavailable device name: " << subStr;
|
||||
}
|
||||
devices.push_back(subStr);
|
||||
return devices;
|
||||
}
|
||||
void adjustKeyMapValues() {
|
||||
if (_useProfiling) {
|
||||
_keyConfigMap[PluginConfigParams::KEY_PERF_COUNT] = PluginConfigParams::YES;
|
||||
@ -165,6 +203,18 @@ struct PluginConfig {
|
||||
PerfHintsConfig _perfHintsConfig;
|
||||
std::map<std::string, std::string> _passThroughConfig;
|
||||
std::map<std::string, std::string> _keyConfigMap;
|
||||
const std::set<std::string> _availableDevices = {"CPU", "GPU", "GNA", "TEMPLATE", "MYRAID", "HDDL", "VPUX", "MULTI", "HETERO", "CUDA", "HPU_GOYA"};
|
||||
const std::set<std::string> _availableDevices = {"AUTO",
|
||||
"CPU",
|
||||
"GPU",
|
||||
"GNA",
|
||||
"TEMPLATE",
|
||||
"MYRIAD",
|
||||
"HDDL",
|
||||
"VPUX",
|
||||
"MULTI",
|
||||
"HETERO",
|
||||
"CUDA",
|
||||
"HPU_GOYA",
|
||||
"mock"};
|
||||
};
|
||||
} // namespace MultiDevicePlugin
|
@ -31,12 +31,69 @@ const std::vector<ov::AnyMap> auto_multi_properties = {
|
||||
{ov::device::priorities(CommonTestUtils::DEVICE_GPU), ov::intel_auto::device_bind_buffer("NO")}
|
||||
};
|
||||
|
||||
|
||||
const std::vector<ov::AnyMap> multi_properties = {
|
||||
{ov::device::priorities("CPU", "GPU")},
|
||||
{ov::device::priorities("CPU(1)", "GPU")},
|
||||
{ov::device::priorities("CPU(1)", "GPU(2)")}
|
||||
};
|
||||
|
||||
const std::vector<ov::AnyMap> auto_properties = {
|
||||
{ov::device::priorities("CPU", "GPU")},
|
||||
{ov::device::priorities("-CPU", "GPU")},
|
||||
{ov::device::priorities("CPU(1)", "GPU")},
|
||||
{ov::device::priorities("CPU(1)", "GPU(2)")},
|
||||
{ov::device::priorities("CPU", "-GPU")}
|
||||
};
|
||||
|
||||
|
||||
const std::vector<ov::AnyMap> auto_Multi_compiled_empty_properties = {
|
||||
{}
|
||||
};
|
||||
|
||||
const std::vector<ov::AnyMap> multi_plugin_Incorrect_properties = {
|
||||
{ov::device::priorities("NONE")}
|
||||
};
|
||||
const std::vector<ov::AnyMap> auto_plugin_Incorrect_properties = {
|
||||
{ov::device::priorities("NONE", "GPU")},
|
||||
{ov::device::priorities("-", "GPU")},
|
||||
{ov::device::priorities("-NONE", "CPU")},
|
||||
{ov::device::priorities("-CPU", "-NONE")},
|
||||
{ov::device::priorities("-NONE", "-NONE")}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_AutoMultiBehaviorTests, OVPropertiesTests,
|
||||
::testing::Combine(
|
||||
::testing::Values(CommonTestUtils::DEVICE_AUTO, CommonTestUtils::DEVICE_MULTI),
|
||||
::testing::ValuesIn(auto_multi_properties)),
|
||||
OVPropertiesTests::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_AutoBehaviorTests, OVPropertiesTests,
|
||||
::testing::Combine(
|
||||
::testing::Values(CommonTestUtils::DEVICE_AUTO),
|
||||
::testing::ValuesIn(auto_properties)),
|
||||
OVPropertiesTests::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_MultiBehaviorTests, OVPropertiesTests,
|
||||
::testing::Combine(
|
||||
::testing::Values(CommonTestUtils::DEVICE_MULTI),
|
||||
::testing::ValuesIn(multi_properties)),
|
||||
OVPropertiesTests::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_AutoBehaviorIncorrectPropertiesTests, OVSetPropComplieModleWihtIncorrectPropTests,
|
||||
::testing::Combine(
|
||||
::testing::Values(CommonTestUtils::DEVICE_AUTO),
|
||||
::testing::ValuesIn(auto_plugin_Incorrect_properties),
|
||||
::testing::ValuesIn(auto_Multi_compiled_empty_properties)),
|
||||
OVSetPropComplieModleWihtIncorrectPropTests::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_MultiBehaviorIncorrectPropertiesTests, OVSetPropComplieModleWihtIncorrectPropTests,
|
||||
::testing::Combine(
|
||||
::testing::Values(CommonTestUtils::DEVICE_MULTI),
|
||||
::testing::ValuesIn(multi_plugin_Incorrect_properties),
|
||||
::testing::ValuesIn(auto_Multi_compiled_empty_properties)),
|
||||
OVSetPropComplieModleWihtIncorrectPropTests::getTestCaseName);
|
||||
|
||||
const std::vector<ov::AnyMap> gpu_plugin_properties = {
|
||||
{ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT),
|
||||
ov::hint::num_requests(2),
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
|
||||
AnyMap compileModelProperties;
|
||||
};
|
||||
using OVSetPropComplieModleWihtIncorrectPropTests = OVSetPropComplieModleGetPropTests;
|
||||
|
||||
} // namespace behavior
|
||||
} // namespace test
|
||||
|
@ -145,6 +145,15 @@ 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);
|
||||
}
|
||||
|
||||
} // namespace behavior
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
Loading…
Reference in New Issue
Block a user