Eliminated invalid subgraphs (#2196)
This commit is contained in:
parent
e3174fa752
commit
89a6f926a4
@ -175,10 +175,44 @@ void Plugin::QueryNetwork(const ICNNNetwork &network, const ConfigMap& config, Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4. The result set should contains just nodes from supported set
|
// 4. The result set should contains just nodes from supported set
|
||||||
for (auto&& layerName : supported) {
|
for (auto&& unsupportedNode : unsupported) {
|
||||||
if (!contains(unsupported, layerName)) {
|
supported.erase(unsupportedNode);
|
||||||
res.supportedLayersMap.emplace(layerName, GetName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 5. If some housekeeping nodes were not added add them.
|
||||||
|
for (auto&& node : function->get_ops()) {
|
||||||
|
if (contains(supported, node->get_friendly_name())) {
|
||||||
|
for (auto&& inputNodeOutput : node->input_values()) {
|
||||||
|
if (ngraph::op::is_constant(inputNodeOutput.get_node()) || ngraph::op::is_parameter(inputNodeOutput.get_node())) {
|
||||||
|
supported.emplace(inputNodeOutput.get_node()->get_friendly_name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto&& outputs : node->outputs()) {
|
||||||
|
for (auto&& outputNodeInput : outputs.get_target_inputs()) {
|
||||||
|
if (ngraph::op::is_output(outputNodeInput.get_node())) {
|
||||||
|
supported.emplace(outputNodeInput.get_node()->get_friendly_name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. Eliminate subgraphs that consists of housekeeping nodes only
|
||||||
|
for (auto&& node : function->get_ops()) {
|
||||||
|
if (ngraph::op::is_constant(node) || ngraph::op::is_parameter(node)) {
|
||||||
|
if (!contains(supported, node->output(0).get_target_inputs().begin()->get_node()->get_friendly_name())) {
|
||||||
|
supported.erase(node->get_friendly_name());
|
||||||
|
}
|
||||||
|
} else if (ngraph::op::is_output(node)) {
|
||||||
|
if (!contains(supported, node->input_values().begin()->get_node()->get_friendly_name())) {
|
||||||
|
supported.erase(node->get_friendly_name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Produce the result
|
||||||
|
for (auto&& layerName : supported) {
|
||||||
|
res.supportedLayersMap.emplace(layerName, GetName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ! [plugin:query_network]
|
// ! [plugin:query_network]
|
||||||
|
@ -311,11 +311,13 @@ void Engine::QueryNetwork(const ICNNNetwork& network, const std::map<std::string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto&& unsupportedNode : unsupported) {
|
||||||
|
supported.erase(unsupportedNode);
|
||||||
|
}
|
||||||
for (auto&& node : function->get_ops()) {
|
for (auto&& node : function->get_ops()) {
|
||||||
if (!contains(unsupported, node->get_friendly_name())) {
|
if (contains(supported, node->get_friendly_name())) {
|
||||||
for (auto&& inputNodeOutput : node->input_values()) {
|
for (auto&& inputNodeOutput : node->input_values()) {
|
||||||
if (ngraph::op::is_constant(inputNodeOutput.get_node())) {
|
if (ngraph::op::is_constant(inputNodeOutput.get_node()) || ngraph::op::is_parameter(inputNodeOutput.get_node())) {
|
||||||
supported.emplace(inputNodeOutput.get_node()->get_friendly_name());
|
supported.emplace(inputNodeOutput.get_node()->get_friendly_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,11 +330,19 @@ void Engine::QueryNetwork(const ICNNNetwork& network, const std::map<std::string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto&& node : function->get_ops()) {
|
||||||
for (auto&& layerName : supported) {
|
if (ngraph::op::is_constant(node) || ngraph::op::is_parameter(node)) {
|
||||||
if (!contains(unsupported, layerName)) {
|
if (!contains(supported, node->output(0).get_target_inputs().begin()->get_node()->get_friendly_name())) {
|
||||||
res.supportedLayersMap.emplace(layerName, GetName());
|
supported.erase(node->get_friendly_name());
|
||||||
}
|
}
|
||||||
|
} else if (ngraph::op::is_output(node)) {
|
||||||
|
if (!contains(supported, node->input_values().begin()->get_node()->get_friendly_name())) {
|
||||||
|
supported.erase(node->get_friendly_name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto&& layerName : supported) {
|
||||||
|
res.supportedLayersMap.emplace(layerName, GetName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
details::CNNNetworkIterator i(&network);
|
details::CNNNetworkIterator i(&network);
|
||||||
|
Loading…
Reference in New Issue
Block a user