MCPcopy Create free account
hub / github.com/ml-explore/mlx / test_enable_disable

Method test_enable_disable

python/tests/test_compile.py:172–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

170 self.assertEqual(out.item(), 4)
171
172 def test_enable_disable(self):
173 def fun(x):
174 y = x + 1
175 z = x + 1
176 return y + z
177
178 def count_prims(outputs):
179 buf = io.StringIO()
180 mx.export_to_dot(buf, outputs)
181 buf.seek(0)
182 return len([l for l in buf.read().split() if "label" in l])
183
184 x = mx.array(1.0)
185 cfun = mx.compile(fun)
186 n_compiled = count_prims(cfun(x))
187
188 # Check disabled
189 mx.disable_compile()
190 n_uncompiled = count_prims(cfun(x))
191 self.assertTrue(n_compiled < n_uncompiled)
192
193 # Check renabled
194 mx.enable_compile()
195 n_enable_compiled = count_prims(cfun(x))
196 self.assertEqual(n_compiled, n_enable_compiled)
197
198 def test_compile_two_input_grad(self):
199 def loss(w, x):

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.60

Tested by

no test coverage detected