Apply ov::execution_devices to GPU & CPU & AUTO BATCH & MULTI (#14109)
* Apply ov::execution_devices to GPU & CPU & AUTO BATCH & MULTI * Apply ov::execution_devices to GNA Co-authored-by: yanlan song <bell.song@intel.com>
This commit is contained in:
1 parent
31d91033d9
commit
b8636222c3
14 files changed
+110
-14
No files matched your search
@@ -164,7 +164,12 @@ IE::Parameter AutoExecutableNetwork::GetMetric(const std::string& name) const {
|
||||
if (i == 0 && !_autoSchedule->_loadContext[CPU].executableNetwork._ptr) {
|
||||
continue;
|
||||
} else {
|
||||
exeDevices.push_back(_autoSchedule->_loadContext[i].workName.substr(_autoSchedule->_loadContext[i].workName.find(":") + 1));
|
||||
std::string exeDevices_string = _autoSchedule->_loadContext[i].workName.substr(_autoSchedule->_loadContext[i].workName.find(":") + 1);
|
||||
std::stringstream ss(exeDevices_string);
|
||||
std::string item;
|
||||
while (getline(ss, item, ',')) {
|
||||
exeDevices.push_back(item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ IE::Parameter MultiExecutableNetwork::GetMetric(const std::string& name) const {
|
||||
|
||||
// Configs
|
||||
// device priority can be changed on-the-fly in MULTI
|
||||
ov::PropertyName{ov::device::priorities.name(), ov::PropertyMutability::RW}
|
||||
ov::PropertyName{ov::device::priorities.name(), ov::PropertyMutability::RW},
|
||||
ov::PropertyName{ov::execution_devices.name(), ov::PropertyMutability::RO}
|
||||
};
|
||||
} else if (name == ov::optimal_number_of_infer_requests) {
|
||||
unsigned int res = 0u;
|
||||
@@ -133,6 +134,12 @@ IE::Parameter MultiExecutableNetwork::GetMetric(const std::string& name) const {
|
||||
} else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
|
||||
std::vector<std::string> configKeys = {IE::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES};
|
||||
IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, configKeys);
|
||||
} else if (name == ov::execution_devices) {
|
||||
std::vector<std::string> exeDevices = {};
|
||||
for (auto n : _multiSContext->_devicePriorities) {
|
||||
exeDevices.push_back(n.deviceName);
|
||||
}
|
||||
return decltype(ov::available_devices)::value_type {exeDevices};
|
||||
} else {
|
||||
IE_THROW() << "Unsupported ExecutableNetwork metric key: " << name;
|
||||
}
|
||||
|
||||
@@ -645,10 +645,13 @@ InferenceEngine::Parameter AutoBatchExecutableNetwork::GetMetric(const std::stri
|
||||
{METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS),
|
||||
METRIC_KEY(SUPPORTED_METRICS),
|
||||
METRIC_KEY(NETWORK_NAME),
|
||||
METRIC_KEY(SUPPORTED_CONFIG_KEYS)});
|
||||
METRIC_KEY(SUPPORTED_CONFIG_KEYS),
|
||||
ov::execution_devices.name()});
|
||||
} else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
|
||||
IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS,
|
||||
{CONFIG_KEY(AUTO_BATCH_TIMEOUT)}); // only timeout can be changed on the fly
|
||||
} else if (name == ov::execution_devices) {
|
||||
return _networkWithoutBatch->GetMetric(name);
|
||||
} else {
|
||||
IE_THROW() << "Unsupported Network metric: " << name;
|
||||
}
|
||||
|
||||
@@ -312,6 +312,7 @@ InferenceEngine::Parameter ExecNetwork::GetMetric(const std::string &name) const
|
||||
RO_property(ov::hint::inference_precision.name()),
|
||||
RO_property(ov::hint::performance_mode.name()),
|
||||
RO_property(ov::hint::num_requests.name()),
|
||||
RO_property(ov::execution_devices.name()),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -354,6 +355,8 @@ InferenceEngine::Parameter ExecNetwork::GetMetric(const std::string &name) const
|
||||
} else if (name == ov::hint::num_requests) {
|
||||
const auto perfHintNumRequests = config.perfHintsConfig.ovPerfHintNumRequests;
|
||||
return decltype(ov::hint::num_requests)::value_type(perfHintNumRequests);
|
||||
} else if (name == ov::execution_devices) {
|
||||
return decltype(ov::execution_devices)::value_type{_plugin->GetName()};
|
||||
}
|
||||
/* Internally legacy parameters are used with new API as part of migration procedure.
|
||||
* This fallback can be removed as soon as migration completed */
|
||||
|
||||
+9
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "behavior/ov_executable_network/get_metric.hpp"
|
||||
#include "behavior/ov_plugin/properties_tests.hpp"
|
||||
#include "openvino/runtime/core.hpp"
|
||||
|
||||
using namespace ov::test::behavior;
|
||||
@@ -44,6 +45,14 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_OVClassExecutableNetworkGetMetricTest, OVClassExecutableNetworkGetMetricTest_ThrowsUnsupported,
|
||||
::testing::Values("CPU", "MULTI:CPU", "HETERO:CPU", "AUTO:CPU"));
|
||||
|
||||
const std::vector<std::tuple<std::string, std::pair<ov::AnyMap, std::string>>> GetMetricTest_ExecutionDevice_CPU = {
|
||||
{"CPU", std::make_pair(ov::AnyMap{}, "CPU")}};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_OVClassExecutableNetworkGetMetricTest, OVClassExecutableNetworkGetMetricTest_EXEC_DEVICES,
|
||||
::testing::ValuesIn(GetMetricTest_ExecutionDevice_CPU),
|
||||
OVCompileModelGetExecutionDeviceTests::getTestCaseName);
|
||||
|
||||
//
|
||||
// Executable Network GetConfig / SetConfig
|
||||
//
|
||||
|
||||
+4
-3
@@ -89,14 +89,15 @@ INSTANTIATE_TEST_SUITE_P(smoke_AutoBehaviorTests, OVPropertiesDefaultTests,
|
||||
::testing::ValuesIn(default_properties)),
|
||||
OVPropertiesDefaultTests::getTestCaseName);
|
||||
|
||||
const std::vector<std::pair<ov::AnyMap, std::string>> autoExeDeviceConfigs = {
|
||||
const std::vector<std::pair<ov::AnyMap, std::string>> automultiExeDeviceConfigs = {
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_CPU)}}, "CPU")
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_AutoMultiCompileModelBehaviorTests,
|
||||
OVCompileModelGetExecutionDeviceTests,
|
||||
::testing::Combine(::testing::Values(CommonTestUtils::DEVICE_AUTO),
|
||||
::testing::ValuesIn(autoExeDeviceConfigs)),
|
||||
::testing::Combine(::testing::Values(CommonTestUtils::DEVICE_AUTO,
|
||||
CommonTestUtils::DEVICE_MULTI),
|
||||
::testing::ValuesIn(automultiExeDeviceConfigs)),
|
||||
OVCompileModelGetExecutionDeviceTests::getTestCaseName);
|
||||
|
||||
const std::vector<ov::AnyMap> auto_multi_device_properties = {
|
||||
|
||||
@@ -401,6 +401,7 @@ const Parameter Config::GetSupportedProperties(bool compiled) {
|
||||
{ ov::hint::inference_precision.name(), model_mutability },
|
||||
{ ov::hint::num_requests.name(), model_mutability },
|
||||
{ ov::log::level.name(), ov::PropertyMutability::RW },
|
||||
{ ov::execution_devices.name(), ov::PropertyMutability::RO },
|
||||
};
|
||||
return supported_properties;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ Parameter GNAPlugin::GetMetric(const std::string& name, const std::map<std::stri
|
||||
}
|
||||
} else if (ov::intel_gna::library_full_version == name) {
|
||||
return GNADeviceHelper::GetGnaLibraryVersion();
|
||||
} else if (ov::execution_devices == name) {
|
||||
return decltype(ov::execution_devices)::value_type {GetName()};
|
||||
} else {
|
||||
const std::unordered_map<std::string, std::function<Parameter()>> queryApiSupported = {
|
||||
{METRIC_KEY(AVAILABLE_DEVICES), [this]() {return GetAvailableDevices();}},
|
||||
|
||||
+8
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <gna/gna_config.hpp>
|
||||
#include "openvino/runtime/intel_gna/properties.hpp"
|
||||
#include "behavior/ov_plugin/properties_tests.hpp"
|
||||
|
||||
using namespace ov::test::behavior;
|
||||
|
||||
@@ -58,6 +59,13 @@ INSTANTIATE_TEST_SUITE_P(nightly_OVClassGetConfigTest,
|
||||
OVClassGetConfigTest_ThrowUnsupported,
|
||||
::testing::Values("GNA", "MULTI", "HETERO"));
|
||||
|
||||
const std::vector<std::tuple<std::string, std::pair<ov::AnyMap, std::string>>> GetMetricTest_ExecutionDevice_GNA = {
|
||||
{"GNA", std::make_pair(ov::AnyMap{}, "GNA")}};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(nightly_OVClassGetMetricTest,
|
||||
OVClassExecutableNetworkGetMetricTest_EXEC_DEVICES,
|
||||
::testing::ValuesIn(GetMetricTest_ExecutionDevice_GNA),
|
||||
OVCompileModelGetExecutionDeviceTests::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(nightly_OVClassGetAvailableDevices, OVClassGetAvailableDevices, ::testing::Values("GNA"));
|
||||
|
||||
|
||||
@@ -536,7 +536,8 @@ InferenceEngine::Parameter CompiledModel::GetMetric(const std::string &name) con
|
||||
ov::PropertyName{ov::num_streams.name(), PropertyMutability::RO},
|
||||
ov::PropertyName{ov::hint::num_requests.name(), PropertyMutability::RO},
|
||||
ov::PropertyName{ov::hint::inference_precision.name(), PropertyMutability::RO},
|
||||
ov::PropertyName{ov::device::id.name(), PropertyMutability::RO}
|
||||
ov::PropertyName{ov::device::id.name(), PropertyMutability::RO},
|
||||
ov::PropertyName{ov::execution_devices.name(), PropertyMutability::RO}
|
||||
};
|
||||
} else if (name == ov::model_name) {
|
||||
IE_ASSERT(!m_graphs.empty());
|
||||
@@ -559,6 +560,8 @@ InferenceEngine::Parameter CompiledModel::GetMetric(const std::string &name) con
|
||||
if (m_config.perfHintsConfig.ovPerfHint != CONFIG_VALUE(LATENCY))
|
||||
nr *= 2;
|
||||
return decltype(ov::optimal_number_of_infer_requests)::value_type {nr};
|
||||
} else if (name == ov::execution_devices) {
|
||||
return decltype(ov::execution_devices)::value_type{m_context->getDeviceName()};
|
||||
} else {
|
||||
IE_THROW() << "Unsupported ExecutableNetwork metric: " << name;
|
||||
}
|
||||
|
||||
+11
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "behavior/ov_executable_network/get_metric.hpp"
|
||||
#include "behavior/ov_plugin/properties_tests.hpp"
|
||||
#include "openvino/runtime/core.hpp"
|
||||
|
||||
using namespace ov::test::behavior;
|
||||
@@ -34,6 +35,16 @@ INSTANTIATE_TEST_SUITE_P(nightly_OVClassExecutableNetworkGetMetricTest,
|
||||
OVClassExecutableNetworkGetMetricTest_ThrowsUnsupported,
|
||||
::testing::Values("GPU", "MULTI:GPU", "HETERO:GPU", "AUTO:GPU,CPU", "BATCH:GPU"));
|
||||
|
||||
const std::vector<std::tuple<std::string, std::pair<ov::AnyMap, std::string>>> GetMetricTest_ExecutionDevice_GPU = {
|
||||
{"GPU", std::make_pair(ov::AnyMap{}, "GPU.0")},
|
||||
{"GPU.0", std::make_pair(ov::AnyMap{}, "GPU.0")},
|
||||
{"BATCH:GPU", std::make_pair(ov::AnyMap{}, "GPU.0")}};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(nightly_OVClassExecutableNetworkGetMetricTest,
|
||||
OVClassExecutableNetworkGetMetricTest_EXEC_DEVICES,
|
||||
::testing::ValuesIn(GetMetricTest_ExecutionDevice_GPU),
|
||||
OVCompileModelGetExecutionDeviceTests::getTestCaseName);
|
||||
|
||||
auto multiDevicePriorityConfigs = []() {
|
||||
return std::vector<ov::AnyMap>{{ov::device::priorities(CommonTestUtils::DEVICE_CPU)},
|
||||
{ov::device::priorities(CommonTestUtils::DEVICE_GPU)},
|
||||
|
||||
+24
@@ -146,6 +146,24 @@ const std::vector<std::pair<ov::AnyMap, std::string>> autoExeDeviceConfigs = {
|
||||
ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)}}, "CPU,GPU"),
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
|
||||
ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)}}, "GPU,CPU"),
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
|
||||
ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT),
|
||||
ov::hint::allow_auto_batching(true)}}, "GPU,CPU"),
|
||||
#endif
|
||||
};
|
||||
|
||||
const std::vector<std::pair<ov::AnyMap, std::string>> multiExeDeviceConfigs = {
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities("GPU.0")}}, "GPU.0"),
|
||||
#ifdef ENABLE_INTEL_CPU
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU)}}, "GPU,CPU"),
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_CPU, CommonTestUtils::DEVICE_GPU)}}, "CPU,GPU"),
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_CPU, CommonTestUtils::DEVICE_GPU),
|
||||
ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)}}, "CPU,GPU"),
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
|
||||
ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT)}}, "GPU,CPU"),
|
||||
std::make_pair(ov::AnyMap{{ov::device::priorities(CommonTestUtils::DEVICE_GPU, CommonTestUtils::DEVICE_CPU),
|
||||
ov::hint::performance_mode(ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT),
|
||||
ov::hint::allow_auto_batching(true)}}, "GPU,CPU"),
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -155,4 +173,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_AutoMultiCompileModelBehaviorTests,
|
||||
::testing::ValuesIn(autoExeDeviceConfigs)),
|
||||
OVCompileModelGetExecutionDeviceTests::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_MultiCompileModelBehaviorTests,
|
||||
OVCompileModelGetExecutionDeviceTests,
|
||||
::testing::Combine(::testing::Values(CommonTestUtils::DEVICE_MULTI),
|
||||
::testing::ValuesIn(multiExeDeviceConfigs)),
|
||||
OVCompileModelGetExecutionDeviceTests::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
std::string expectedDeviceName;
|
||||
};
|
||||
|
||||
using OVClassExecutableNetworkGetMetricTest_EXEC_DEVICES = OVCompileModelGetExecutionDeviceTests;
|
||||
} // namespace behavior
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
@@ -191,29 +191,47 @@ void OVCompileModelGetExecutionDeviceTests::SetUp() {
|
||||
TEST_P(OVCompileModelGetExecutionDeviceTests, CanGetExecutionDeviceInfo) {
|
||||
ov::CompiledModel exeNetWork;
|
||||
auto deviceList = core->get_available_devices();
|
||||
std::string updatedExpectDevices = expectedDeviceName;
|
||||
std::vector<std::string> expected_devices = util::split(expectedDeviceName, ',');
|
||||
std::vector<std::string> updatedExpectDevices;
|
||||
updatedExpectDevices.assign(expected_devices.begin(), expected_devices.end());
|
||||
for (auto &iter : compileModelProperties) {
|
||||
if (iter.first == ov::hint::performance_mode && iter.second.as<ov::hint::PerformanceMode>() == ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT) {
|
||||
std::vector<std::string> expected_devices = util::split(expectedDeviceName, ',');
|
||||
std::vector<std::string> sameTypeDevices;
|
||||
if ((iter.first == ov::hint::performance_mode && iter.second.as<ov::hint::PerformanceMode>() == ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT) ||
|
||||
target_device.find("MULTI") != std::string::npos) {
|
||||
for (auto& deviceName : expected_devices) {
|
||||
for (auto&& device : deviceList) {
|
||||
if (device.find(deviceName) != std::string::npos) {
|
||||
sameTypeDevices.push_back(std::move(device));
|
||||
auto updatedExpectDevices_iter = std::find(updatedExpectDevices.begin(), updatedExpectDevices.end(), deviceName);
|
||||
if (updatedExpectDevices_iter != updatedExpectDevices.end())
|
||||
updatedExpectDevices.erase(updatedExpectDevices_iter);
|
||||
updatedExpectDevices.push_back(std::move(device));
|
||||
}
|
||||
}
|
||||
}
|
||||
updatedExpectDevices = util::join(sameTypeDevices, ",");
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::sort(updatedExpectDevices.begin(), updatedExpectDevices.end());
|
||||
OV_ASSERT_NO_THROW(exeNetWork = core->compile_model(model, target_device, compileModelProperties));
|
||||
ov::Any property;
|
||||
OV_ASSERT_NO_THROW(property = exeNetWork.get_property(ov::execution_devices));
|
||||
std::vector<std::string> property_vector = property.as<std::vector<std::string>>();
|
||||
std::sort(property_vector.begin(), property_vector.end());
|
||||
if (expectedDeviceName.find("undefined") == std::string::npos)
|
||||
ASSERT_EQ(util::join(property.as<std::vector<std::string>>(), ","), updatedExpectDevices);
|
||||
ASSERT_EQ(property_vector, updatedExpectDevices);
|
||||
else
|
||||
ASSERT_FALSE(property.empty());
|
||||
}
|
||||
|
||||
TEST_P(OVClassExecutableNetworkGetMetricTest_EXEC_DEVICES, CanGetExecutionDeviceInfo) {
|
||||
ov::Core ie = createCoreWithTemplate();
|
||||
std::vector<std::string> expectedTargets = {expectedDeviceName};
|
||||
auto compiled_model = ie.compile_model(model, target_device, compileModelProperties);
|
||||
|
||||
std::vector<std::string> exeTargets;
|
||||
OV_ASSERT_NO_THROW(exeTargets = compiled_model.get_property(ov::execution_devices));
|
||||
|
||||
ASSERT_EQ(expectedTargets, exeTargets);
|
||||
}
|
||||
} // namespace behavior
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
Reference in new issue
Block a user