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

Method test_multi_output_leak

python/tests/test_array.py:1966–1992  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1964 self.assertTrue(mx.array_equal(mx.array(a), mx.array(b)))
1965
1966 def test_multi_output_leak(self):
1967 def fun():
1968 a = mx.zeros((2**20))
1969 mx.eval(a)
1970 b, c = mx.divmod(a, a)
1971 del b, c
1972
1973 fun()
1974 mx.synchronize()
1975 peak_1 = mx.get_peak_memory()
1976 fun()
1977 mx.synchronize()
1978 peak_2 = mx.get_peak_memory()
1979 self.assertEqual(peak_1, peak_2)
1980
1981 def fun():
1982 a = mx.array([1.0, 2.0, 3.0, 4.0])
1983 b, _ = mx.divmod(a, a)
1984 return mx.log(b)
1985
1986 fun()
1987 mx.synchronize()
1988 peak_1 = mx.get_peak_memory()
1989 fun()
1990 mx.synchronize()
1991 peak_2 = mx.get_peak_memory()
1992 self.assertEqual(peak_1, peak_2)
1993
1994 def test_add_numpy(self):
1995 x = mx.array(1)

Callers

nothing calls this directly

Calls 2

synchronizeMethod · 0.45
get_peak_memoryMethod · 0.45

Tested by

no test coverage detected