[AUTO] AUTO can't fall back if target device throws the exception before compiling model via AUTO (#18311)

* 1. Update AUTO candidate device filtering logic.
2. Add AUTO handling the exception logic when generating the target device infomation.

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

* Update.

* Update.

* Update.

* Update.

---------

Signed-off-by: Wang, Yang <yang4.wang@intel.com>
Co-authored-by: Chen Peter <peter.chen@intel.com>
This commit is contained in:
Wang, YangandChen Peter authored and GitHub committed 2023-07-13 09:09:25 +08:00
1 parent 63b18adf68
commit 7b9f6c47b1
3 files changed
+79 -44

No files matched your search

+13 -2
View File
@@ -261,8 +261,19 @@ std::vector<DeviceInformation> Plugin::parse_meta_devices(const std::string& pri
LOG_DEBUG_TAG("deviceNameWithID:%s, defaultDeviceID:%s, uniqueName:%s",
device_name_with_id.c_str(), default_device_id.c_str(), unique_name.c_str());
// create meta device
meta_devices.push_back({device_name_with_id, get_device_config(device_name_with_id),
num_requests, default_device_id, unique_name, device_priority});
try {
meta_devices.push_back({device_name_with_id,
get_device_config(device_name_with_id),
num_requests,
default_device_id,
unique_name,
device_priority});
} catch (const ov::Exception&) {
LOG_DEBUG_TAG("Failed to create meta device for deviceNameWithID:%s, defaultDeviceID:%s, uniqueName:%s",
device_name_with_id.c_str(),
default_device_id.c_str(),
unique_name.c_str());
}
}
if (enable_device_priority) {
device_priority++;
@@ -133,7 +133,10 @@ const std::vector<Params> testConfigs = {Params{" ", " "},
Params{"CPU,GPU.1,GPU", "CPU,GPU.1,GPU"},
Params{"CPU,VPUX", "CPU,VPUX"},
Params{"CPU,-VPUX", "CPU"},
Params{"INVALID_DEVICE", "INVALID_DEVICE"},
Params{"CPU,-INVALID_DEVICE", "CPU"},
Params{"CPU,INVALID_DEVICE", "CPU,INVALID_DEVICE"},
Params{"-CPU,INVALID_DEVICE", "INVALID_DEVICE"},
Params{"CPU,GPU,VPUX", "CPU,GPU,VPUX"}};
const std::vector<Params> testConfigsWithIdNotInteldGPU = {Params{" ", " "},
@@ -6,22 +6,24 @@
using namespace ov::mock_auto_plugin;
using Config = std::map<std::string, std::string>;
using testing::Throw;
const char igpuFullDeviceName[] = "Intel(R) Gen9 HD Graphics (iGPU)";
const char dgpuFullDeviceName[] = "Intel(R) Iris(R) Xe MAX Graphics (dGPU)";
const std::vector<std::string> availableDevsNoID = {"CPU", "GPU", "VPUX"};
using ConfigParams = std::tuple<
std::string, // Priority devices
std::vector<DeviceInformation>, // expect metaDevices
bool // if throw exception
>;
using ConfigParams = std::tuple<std::string, // Priority devices
std::vector<DeviceInformation>, // expect metaDevices
bool, // if throw exception
int // expected times of calling get_supported_property()
>;
class ParseMetaDeviceTest : public tests::AutoTest, public ::testing::TestWithParam<ConfigParams> {
public:
static std::string getTestCaseName(testing::TestParamInfo<ConfigParams> obj) {
std::string priorityDevices;
std::vector<DeviceInformation> metaDevices;
bool throwException;
std::tie(priorityDevices, metaDevices, throwException) = obj.param;
int expectedTimes;
std::tie(priorityDevices, metaDevices, throwException, expectedTimes) = obj.param;
std::ostringstream result;
result << "priorityDevices_" << priorityDevices;
if (throwException) {
@@ -29,16 +31,17 @@ public:
} else {
result << "_throwException_false";
}
result << "_expectedGetSupportedProperty_" << expectedTimes;
return result.str();
}
void SetUp() override {
ON_CALL(*core, get_supported_property(StrEq("INVALID_DEVICE"), _)).WillByDefault(Throw(ov::Exception("")));
ON_CALL(*plugin, parse_meta_devices).WillByDefault([this](const std::string& priorityDevices,
const ov::AnyMap& config) {
return plugin->Plugin::parse_meta_devices(priorityDevices, config);
});
std::tie(priorityDevices, metaDevices, throwException) = GetParam();
sizeOfMetaDevices = static_cast<int>(metaDevices.size());
std::tie(priorityDevices, metaDevices, throwException, expectedTimes) = GetParam();
}
void compare(std::vector<DeviceInformation>& result, std::vector<DeviceInformation>& expect) {
@@ -67,7 +70,7 @@ protected:
std::string priorityDevices;
std::vector<DeviceInformation> metaDevices;
bool throwException;
int sizeOfMetaDevices;
int expectedTimes;
};
using ParseMetaDeviceNoIDTest = ParseMetaDeviceTest;
@@ -75,7 +78,7 @@ TEST_P(ParseMetaDeviceTest, ParseMetaDevicesWithPriority) {
EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1);
EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber());
EXPECT_CALL(*core, get_available_devices()).Times(1);
EXPECT_CALL(*core, get_supported_property(_, _)).Times(sizeOfMetaDevices);
EXPECT_CALL(*core, get_supported_property(_, _)).Times(expectedTimes);
if (throwException) {
ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {}));
} else {
@@ -110,7 +113,7 @@ TEST_P(ParseMetaDeviceNoIDTest, ParseMetaDevices) {
EXPECT_CALL(*plugin, parse_meta_devices(_, _)).Times(1);
EXPECT_CALL(*core, get_property(_, _, _)).Times(AnyNumber());
EXPECT_CALL(*core, get_available_devices()).Times(1);
EXPECT_CALL(*core, get_supported_property(_, _)).Times(sizeOfMetaDevices);
EXPECT_CALL(*core, get_supported_property(_, _)).Times(expectedTimes);
if (throwException) {
ASSERT_ANY_THROW(plugin->parse_meta_devices(priorityDevices, {}));
} else {
@@ -124,43 +127,61 @@ TEST_P(ParseMetaDeviceNoIDTest, ParseMetaDevices) {
// ConfigParams {devicePriority, expect metaDevices, ifThrowException}
const std::vector<ConfigParams> testConfigs = {
ConfigParams {"CPU,GPU,VPUX",
{{"CPU", {}, -1, "", "CPU_", 0},
{"GPU.0", {}, -1, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"VPUX", {}, -1, "", "VPUX_", 2}}, false},
ConfigParams {"VPUX,GPU,CPU",
{{"VPUX", {}, -1, "", "VPUX_", 0},
{"GPU.0", {}, -1, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"CPU", {}, -1, "", "CPU_", 2}}, false},
ConfigParams {"CPU(1),GPU(2),VPUX(4)",
{{"CPU", {}, 1, "", "CPU_", 0},
{"GPU.0", {}, 2, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, 2, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"VPUX", {}, 4, "", "VPUX_", 2}}, false},
ConfigParams{"CPU,GPU,VPUX",
{{"CPU", {}, -1, "", "CPU_", 0},
{"GPU.0", {}, -1, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"VPUX", {}, -1, "", "VPUX_", 2}},
false,
4},
ConfigParams{"VPUX,GPU,CPU",
{{"VPUX", {}, -1, "", "VPUX_", 0},
{"GPU.0", {}, -1, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"CPU", {}, -1, "", "CPU_", 2}},
false,
4},
ConfigParams{"VPUX,GPU,INVALID_DEVICE",
{{"VPUX", {}, -1, "", "VPUX_", 0},
{"GPU.0", {}, -1, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1}},
false,
3},
ConfigParams{"CPU(1),GPU(2),VPUX(4)",
{{"CPU", {}, 1, "", "CPU_", 0},
{"GPU.0", {}, 2, "", std::string(igpuFullDeviceName) + "_0", 1},
{"GPU.1", {}, 2, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"VPUX", {}, 4, "", "VPUX_", 2}},
false,
4},
ConfigParams {"CPU(-1),GPU,VPUX", {}, true},
ConfigParams {"CPU(NA),GPU,VPUX", {}, true},
ConfigParams{"CPU(-1),GPU,VPUX", {}, true, 0},
ConfigParams{"CPU(NA),GPU,VPUX", {}, true, 0},
ConfigParams{"INVALID_DEVICE", {}, false, 0},
ConfigParams{"INVALID_DEVICE,CPU", {{"CPU", {}, -1, "", "CPU_", 1}}, false, 2},
ConfigParams {"CPU(3),GPU.1,VPUX",
{{"CPU", {}, 3, "", "CPU_", 0},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"VPUX", {}, -1, "", "VPUX_", 2}}, false},
ConfigParams {"VPUX,GPU.1,CPU(3)",
{{"VPUX", {}, -1, "", "VPUX_", 0},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"CPU", {}, 3, "", "CPU_", 2}}, false}
};
ConfigParams{"CPU(3),GPU.1,VPUX",
{{"CPU", {}, 3, "", "CPU_", 0},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"VPUX", {}, -1, "", "VPUX_", 2}},
false,
3},
ConfigParams{"VPUX,GPU.1,CPU(3)",
{{"VPUX", {}, -1, "", "VPUX_", 0},
{"GPU.1", {}, -1, "", std::string(dgpuFullDeviceName) + "_1", 1},
{"CPU", {}, 3, "", "CPU_", 2}},
false,
3}};
const std::vector<ConfigParams> testConfigsNoID = {
ConfigParams {"CPU,GPU,VPUX",
{{"CPU", {}, -1, "", "CPU_", 0},
{"GPU", {}, -1, "0", std::string(igpuFullDeviceName) + "_0", 1},
{"VPUX", {}, -1, "", "VPUX_", 2}}, false},
ConfigParams{"CPU,GPU,VPUX",
{{"CPU", {}, -1, "", "CPU_", 0},
{"GPU", {}, -1, "0", std::string(igpuFullDeviceName) + "_0", 1},
{"VPUX", {}, -1, "", "VPUX_", 2}},
false,
3},
};
INSTANTIATE_TEST_SUITE_P(smoke_Auto_BehaviorTests, ParseMetaDeviceTest,
::testing::ValuesIn(testConfigs),
ParseMetaDeviceTest::getTestCaseName);