[HETERO] Return only own properties for compiled model (#15547)

This commit is contained in:
Nadezhda Ageeva
2023-02-07 23:54:08 +04:00
committed by GitHub
parent 26108b1b67
commit 421d791f58
2 changed files with 5 additions and 106 deletions

View File

@@ -833,58 +833,12 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetConfig(const std::string&
IE_ASSERT(it != _config.end());
result = it->second == YES ? true : false;
} else {
// find config key among plugin config keys
for (auto&& desc : _networks) {
auto execNetwork = desc._network;
auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS));
for (auto&& configKey : param.as<std::vector<std::string>>()) {
if (configKey == name) {
return execNetwork->GetConfig(configKey);
}
}
}
IE_THROW() << "Unsupported ExecutableNetwork config key: " << name;
}
return result;
}
using Metrics = std::map<std::string, Parameter>;
namespace {
void collectPluginMetrics(std::vector<std::string>& baseMetrics, const std::vector<::Metrics> pluginMetrics) {
// check whether the metric has unique name and value among all the plugins
auto isMetricValueUnique = [&](const std::string& key, const Parameter& value) -> bool {
if (std::find(baseMetrics.begin(), baseMetrics.end(), key) != baseMetrics.end())
return false;
for (auto&& metrics : pluginMetrics) {
for (auto&& metric : metrics)
if (key == metric.first && value != metric.second)
return false;
}
return true;
};
// collect only unique metrics
std::vector<std::string> uniqueMetrics;
for (auto&& metrics : pluginMetrics) {
for (auto&& metric : metrics) {
if (isMetricValueUnique(metric.first, metric.second)) {
uniqueMetrics.push_back(metric.first);
}
}
}
// add plugin specific metrics which don't conflict with base ones
std::copy(uniqueMetrics.begin(), uniqueMetrics.end(), std::back_inserter(baseMetrics));
}
} // namespace
InferenceEngine::Parameter HeteroExecutableNetwork::GetMetric(const std::string& name) const {
if (EXEC_NETWORK_METRIC_KEY(SUPPORTED_METRICS) == name) {
std::vector<std::string> heteroMetrics = {ov::model_name.name(),
@@ -892,44 +846,12 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetMetric(const std::string&
METRIC_KEY(SUPPORTED_CONFIG_KEYS),
ov::optimal_number_of_infer_requests.name(),
ov::execution_devices.name()};
{
std::vector<::Metrics> pluginMetrics;
for (auto&& desc : _networks) {
auto execNetwork = desc._network;
auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_METRICS));
::Metrics metrics;
for (auto&& metricName : param.as<std::vector<std::string>>()) {
metrics[metricName] = execNetwork->GetMetric(metricName);
}
pluginMetrics.push_back(std::move(metrics));
}
collectPluginMetrics(heteroMetrics, pluginMetrics);
}
IE_SET_METRIC_RETURN(SUPPORTED_METRICS, heteroMetrics);
} else if (EXEC_NETWORK_METRIC_KEY(SUPPORTED_CONFIG_KEYS) == name) {
std::vector<std::string> heteroConfigKeys = {"TARGET_FALLBACK",
ov::device::priorities.name(),
HETERO_CONFIG_KEY(DUMP_GRAPH_DOT),
CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS)};
{
std::vector<::Metrics> pluginConfigKeys;
for (auto&& desc : _networks) {
auto execNetwork = desc._network;
auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS));
::Metrics configKeys;
for (auto&& metricName : param.as<std::vector<std::string>>()) {
configKeys[metricName] = execNetwork->GetConfig(metricName);
}
pluginConfigKeys.push_back(std::move(configKeys));
}
collectPluginMetrics(heteroConfigKeys, pluginConfigKeys);
}
IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, heteroConfigKeys);
} else if (ov::model_name == name) {
return decltype(ov::model_name)::value_type{_name};
@@ -951,17 +873,6 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetMetric(const std::string&
}
return decltype(ov::execution_devices)::value_type{exeDevices};
} else {
// find metric key among plugin metrics
for (auto&& desc : _networks) {
auto execNetwork = desc._network;
auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_METRICS));
for (auto&& metricKey : param.as<std::vector<std::string>>()) {
if (metricKey == name) {
return execNetwork->GetMetric(metricKey);
}
}
}
IE_THROW() << "Unsupported ExecutableNetwork metric key: " << name;
}
}