mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-24 14:28:09 -05:00
* cpu tests pass * torch works * works * metal works * fix ops_disk * metal jit works * fix openpilot * llvm and clang work * fix webgpu * docs are rly broken * LRU works on metal * delete comment * revert name to ._buf. LRU only on Compiled * changes * allocator * allocator, getting closer * lru alloc * LRUAllocator * all pass * metal * cuda * test examples * linearizer * test fixes * fix custom + clean realize * fix hip * skip tests * fix tests * fix size=0 * fix MOCKHIP * fix thneed * copy better * simple * old style metal copy * fix thneed * np reshape * give cuda a device
21 lines
877 B
Python
21 lines
877 B
Python
import unittest
|
|
|
|
from tinygrad.codegen.linearizer import Linearizer
|
|
from tinygrad.features.search import time_linearizer
|
|
from tinygrad.device import Compiled, Device, Buffer
|
|
from tinygrad.ops import LoadOps
|
|
from tinygrad.tensor import Tensor
|
|
|
|
class TestTimeLinearizer(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
if not isinstance(Device[Device.DEFAULT], Compiled): raise unittest.SkipTest("only test for compiled backends")
|
|
|
|
def test_reasonable_time(self):
|
|
si = [si for si in Tensor([1,2,3,4]).add(1).lazydata.schedule() if si.ast.op not in LoadOps][0]
|
|
rawbufs = [Buffer(Device.DEFAULT, si.out.st.size(), si.out.dtype)] + [Buffer(Device.DEFAULT, x.st.size(), x.dtype) for x in si.inputs]
|
|
tm = time_linearizer(Linearizer(si.ast), rawbufs, allow_test_size=False, cnt=10)
|
|
assert tm > 0 and tm != float('inf')
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|