limit metal buffers and revert the 207 fix (try 2) (#2088)

* limit metal buffers

* look at the base, not the srcs

* Revert "Revert "openpilot kernel fix from 209 to 207 (#2006)" (#2065)"

This reverts commit 924ecc4d6a.

* add a test for that
This commit is contained in:
George Hotz
2023-10-16 14:52:16 -07:00
committed by GitHub
parent e8fcd2f3db
commit 5e24dc5a95
4 changed files with 31 additions and 11 deletions

View File

@@ -326,5 +326,17 @@ class TestSchedule(unittest.TestCase):
out = x.to('cpu')
check_schedule(out, 0, filter_loadops=False)
@unittest.skipUnless(Device.DEFAULT == "METAL", "only for metal")
def test_metal_limit_buffers(self):
t = sum([Tensor([1,2,3,4]) for _ in range(40)])
for si in t.lazydata.schedule():
assert len(si.inputs) <= 30
@unittest.skipUnless(Device.DEFAULT == "METAL", "only for metal")
def test_metal_dont_limit_same_buffers(self):
bt = Tensor(list(range(1, 100)))
out = sum([bt[i:i+2] for i in range(1,40)])
check_schedule(out, 1)
if __name__ == '__main__':
unittest.main(verbosity=2)