| 99 | // Current implementation supports pattern maching toward node's inputs only. |
| 100 | template <> |
| 101 | bool SubGraphMatcher<MatchingDirection::kFollowInputs>::GetMatchedNodes( |
| 102 | const OpTypePattern& pattern, MutableNodeView* node_view, |
| 103 | std::map<string, int>* matched_nodes_map, |
| 104 | std::set<int>* remove_node_indices) { |
| 105 | bool found_match = false; |
| 106 | match_.reset(new NodeViewMatch()); |
| 107 | if (DoesOpTypePatternMatch(pattern, node_view, match_.get())) { |
| 108 | if (!HasRemoveNodeExternalDependents()) { |
| 109 | found_match = true; |
| 110 | matched_nodes_map->swap(this->node_label_to_index_); |
| 111 | remove_node_indices->swap(this->remove_node_indices_); |
| 112 | } |
| 113 | } else { |
| 114 | found_match = false; |
| 115 | // Clear all bookkeeping data |
| 116 | match_->Clear(); |
| 117 | match_.reset(nullptr); |
| 118 | node_label_to_index_.clear(); |
| 119 | matched_node_indices_.clear(); |
| 120 | remove_node_indices_.clear(); |
| 121 | } |
| 122 | return found_match; |
| 123 | } |
| 124 | |
| 125 | } // namespace utils |
| 126 | } // namespace grappler |