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

Method test_has_users

backends/mlx/test/test_pattern_utils.py:119–132  ·  view source on GitHub ↗

Test node that has users.

(self)

Source from the content-addressed store, hash-verified

117 """Tests for has_no_users function."""
118
119 def test_has_users(self):
120 """Test node that has users."""
121 from executorch.backends.mlx.pattern_utils import has_no_users
122
123 class SimpleModule(torch.nn.Module):
124 def forward(self, x):
125 y = torch.neg(x)
126 return y + 1
127
128 graph = get_exported_graph(SimpleModule(), (torch.randn(4, 4),))
129 neg_node = find_node_by_target(graph, "neg")
130
131 self.assertIsNotNone(neg_node)
132 self.assertFalse(has_no_users(neg_node))
133
134 def test_no_users_after_removal(self):
135 """Test has_no_users returns True for orphaned nodes."""

Callers

nothing calls this directly

Calls 4

has_no_usersFunction · 0.90
find_node_by_targetFunction · 0.85
get_exported_graphFunction · 0.70
SimpleModuleClass · 0.70

Tested by

no test coverage detected