| 2192 | self.assertEqual(f"{a}", "array([1, 2, 3], dtype=int32)") |
| 2193 | |
| 2194 | def test_deep_graphs(self): |
| 2195 | # The following tests should simply run cleanly without a segfault or |
| 2196 | # crash due to exceeding recursion depth limits. |
| 2197 | |
| 2198 | # Deep graph destroyed without eval |
| 2199 | x = mx.array([1.0, 2.0]) |
| 2200 | for _ in range(100_000): |
| 2201 | x = mx.sin(x) |
| 2202 | del x |
| 2203 | |
| 2204 | # Duplicate input deep graph destroyed without eval |
| 2205 | x = mx.array([1.0, 2.0]) |
| 2206 | for _ in range(100_000): |
| 2207 | x = x + x |
| 2208 | |
| 2209 | # Deep graph with siblings destroyed without eval |
| 2210 | x = mx.array([1, 2]) |
| 2211 | for _ in range(100_000): |
| 2212 | x = mx.concatenate(mx.split(x, 2)) |
| 2213 | del x |
| 2214 | |
| 2215 | # Deep graph with eval |
| 2216 | x = mx.array([1.0, 2.0]) |
| 2217 | for _ in range(100_000): |
| 2218 | x = mx.sin(x) |
| 2219 | mx.eval(x) |
| 2220 | |
| 2221 | @unittest.skipIf(platform.system() == "Windows", "Memory info not accurate") |
| 2222 | def test_siblings_without_eval(self): |