Skip to content

Commit

Permalink
Move device name validation into meta plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
riverlijunjie committed Mar 11, 2024
1 parent 78aa44a commit 706eec4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
10 changes: 0 additions & 10 deletions src/inference/src/dev/core_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,6 @@ bool ov::is_config_applicable(const std::string& user_device_name, const std::st
ov::Parsed ov::parseDeviceNameIntoConfig(const std::string& deviceName,
const AnyMap& config,
const bool keep_core_property) {
// check to the validity of device name
auto bracket_pos = deviceName.find(")");
while (bracket_pos != std::string::npos) {
if (bracket_pos < deviceName.length() - 1 &&
(deviceName[bracket_pos + 1] != ',' || bracket_pos + 1 == deviceName.length() - 1)) {
OPENVINO_THROW("Device with \"", deviceName, "\" name is illegal in the OpenVINO Runtime");
}
bracket_pos = deviceName.find(")", bracket_pos + 1);
}

auto updated_config = config;
auto updated_device_name = deviceName;

Expand Down
4 changes: 0 additions & 4 deletions src/inference/tests/unit/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,6 @@ TEST(CoreTests_parse_device_config, get_device_config) {
ov::AnyMap{ov::device::priorities("MULTI,DEVICE"),
ov::device::properties(ov::AnyMap{{"MULTI", ov::AnyMap{ov::device::priorities("DEVICE")}}})});

// invalid device name with characters after parenthesis except comma
EXPECT_THROW(ov::parseDeviceNameIntoConfig("DEVICE(0)ov", ov::AnyMap{}), ov::Exception);
EXPECT_THROW(ov::parseDeviceNameIntoConfig("MULTI:DEVICE(0)ov,DEVICE(1)", ov::AnyMap{}), ov::Exception);
EXPECT_THROW(ov::parseDeviceNameIntoConfig("MULTI:DEVICE(0),DEVICE(1),", ov::AnyMap{}), ov::Exception);
}

class ApplyAutoBatchThreading : public testing::Test {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/auto/tests/unit/parse_meta_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const std::vector<ConfigParams> testConfigs = {
ConfigParams{"CPU(-1),GPU,OTHER", {}, true, 0},
ConfigParams{"CPU(NA),GPU,OTHER", {}, true, 0},
ConfigParams{"CPU(4)a", {}, true, 0},
ConfigParams{"CPU(4),", {}, true, 0},
ConfigParams{"CPU(4)a,GPU,OTHER", {}, true, 0},
ConfigParams{"INVALID_DEVICE", {}, false, 0},
ConfigParams{"INVALID_DEVICE,CPU", {{"CPU", {}, -1, "", "CPU_", 1}}, false, 2},
Expand Down

0 comments on commit 706eec4

Please sign in to comment.