[GPU] Improve IsNodeOnConstPath() method (#7458)
This commit is contained in:
parent
377f46898c
commit
e2272331be
@ -325,28 +325,24 @@ void Program::InitProfileInfo(const std::string& layerName,
|
||||
|
||||
// TODO: Does it make sense to add such method to ngraph core?
|
||||
bool IsNodeOnConstPath(const std::shared_ptr<ngraph::Node>& node) {
|
||||
std::list<std::shared_ptr<ngraph::Node>> nodes_to_process = { node };
|
||||
while (!nodes_to_process.empty()) {
|
||||
auto current_node = nodes_to_process.front();
|
||||
nodes_to_process.pop_front();
|
||||
|
||||
for (size_t i = 0; i < current_node->get_input_size(); i++) {
|
||||
auto input_node = current_node->get_input_node_shared_ptr(i);
|
||||
|
||||
std::set<std::shared_ptr<ngraph::Node>> nodes_processed = {};
|
||||
std::function<bool(const std::shared_ptr<ngraph::Node>&)> is_const_node = [&nodes_processed, &is_const_node](const std::shared_ptr<ngraph::Node>& node) {
|
||||
if (nodes_processed.count(node)) return true;
|
||||
nodes_processed.insert(node);
|
||||
// If input is constant, then drop if from the processing list
|
||||
if (std::dynamic_pointer_cast<ngraph::op::v0::Constant>(input_node) != nullptr)
|
||||
continue;
|
||||
|
||||
if (std::dynamic_pointer_cast<ngraph::op::v0::Constant>(node) != nullptr)
|
||||
return true;
|
||||
// If the node doesn't have any parents and it's not a constant, then we deal with dynamic path
|
||||
if (input_node->get_input_size() == 0) {
|
||||
if (node->get_input_size() == 0)
|
||||
return false;
|
||||
for (size_t i = 0; i < node->get_input_size(); i++) {
|
||||
auto input_node = node->get_input_node_shared_ptr(i);
|
||||
if (!is_const_node(input_node))
|
||||
return false;
|
||||
}
|
||||
|
||||
nodes_to_process.insert(nodes_to_process.end(), input_node);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
return is_const_node(node);
|
||||
}
|
||||
|
||||
} // namespace CLDNNPlugin
|
||||
|
Loading…
Reference in New Issue
Block a user