Skip to content

Commit

Permalink
Fix the case where comma is located in the last character.
Browse files Browse the repository at this point in the history
  • Loading branch information
awayzjj authored Mar 4, 2024
1 parent 3c07b2d commit 9ac0d48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/inference/src/dev/core_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ ov::Parsed ov::parseDeviceNameIntoConfig(const std::string& deviceName,
// 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] != ',') {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/inference/tests/unit/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ TEST(CoreTests_parse_device_config, get_device_config) {
// 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_NO_THROW(ov::parseDeviceNameIntoConfig("MULTI:DEVICE(0),DEVICE(1),", ov::AnyMap{}));
EXPECT_THROW(ov::parseDeviceNameIntoConfig("MULTI:DEVICE(0),DEVICE(1),", ov::AnyMap{}), ov::Exception);
}

class ApplyAutoBatchThreading : public testing::Test {
Expand Down

0 comments on commit 9ac0d48

Please sign in to comment.