Test OpStep.matches with op field.
(self)
| 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.""" |
nothing calls this directly
no test coverage detected