MCPcopy Create free account
hub / github.com/pytorch/executorch / matches

Method matches

backends/mlx/pattern_utils.py:156–178  ·  view source on GitHub ↗

Check if this step fully matches the given node.

(self, node: Node)

Source from the content-addressed store, hash-verified

154 arg_index: int = 0
155
156 def matches(self, node: Node) -> bool:
157 """Check if this step fully matches the given node."""
158 # Check op or predicate
159 if self.op is not None:
160 if not match_target(node, self.op):
161 return False
162 elif self.predicate is not None:
163 if not self.predicate(node):
164 return False
165 else:
166 return False
167
168 # Check single user requirement
169 if self.require_single_user and not has_single_user(node):
170 return False
171
172 # Check nargs and kwargs
173 if not self._check_nargs(node):
174 return False
175 if not self._check_kwargs(node):
176 return False
177
178 return True
179
180 def _check_nargs(self, node: Node) -> bool:
181 """Check if node has the required number of args."""

Calls 4

_check_nargsMethod · 0.95
_check_kwargsMethod · 0.95
match_targetFunction · 0.85
has_single_userFunction · 0.85