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

Method test_matches_with_op

backends/mlx/test/test_pattern_utils.py:166–181  ·  view source on GitHub ↗

Test OpStep.matches with op field.

(self)

Source from the content-addressed store, hash-verified

164 """Tests for OpStep dataclass."""
165
166 def test_matches_with_op(self):
167 """Test OpStep.matches with op field."""
168 from executorch.backends.mlx.pattern_utils import OpStep
169
170 class SimpleModule(torch.nn.Module):
171 def forward(self, x):
172 return torch.rsqrt(x)
173
174 graph = get_exported_graph(SimpleModule(), (torch.randn(4, 4),))
175 rsqrt_node = find_node_by_target(graph, "rsqrt")
176
177 step = OpStep(op=torch.ops.aten.rsqrt.default)
178 self.assertTrue(step.matches(rsqrt_node))
179
180 step_wrong = OpStep(op=torch.ops.aten.neg.default)
181 self.assertFalse(step_wrong.matches(rsqrt_node))
182
183 def test_matches_with_predicate(self):
184 """Test OpStep.matches with predicate field."""

Callers

nothing calls this directly

Calls 5

matchesMethod · 0.95
OpStepClass · 0.90
find_node_by_targetFunction · 0.85
get_exported_graphFunction · 0.70
SimpleModuleClass · 0.70

Tested by

no test coverage detected