mirror of https://github.com/commaai/tinygrad.git
add test coverage for search (#2104)
* add test coverage for search * only in compiled backends * dont use device.default in decorator * time_til is the other way around xd
This commit is contained in:
parent
7268b3c6fb
commit
36d4001b4f
|
@ -0,0 +1,16 @@
|
|||
import unittest
|
||||
|
||||
from tinygrad.codegen.linearizer import Linearizer
|
||||
from tinygrad.features.search import time_linearizer
|
||||
from tinygrad.ops import Compiled, Device, 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 = [Device[Device.DEFAULT].buffer(si.out.st.size(), si.out.dtype)] + [Device[Device.DEFAULT].buffer(x.st.size(), x.dtype) for x in si.inputs]
|
||||
tm = time_linearizer(Linearizer(si.ast), rawbufs, allow_test_size=False, cnt=10, should_copy=False)
|
||||
assert tm > 0 and tm != float('inf')
|
|
@ -33,7 +33,7 @@ if getenv("CUDACPU", 0) == 1:
|
|||
class Event:
|
||||
def __init__(self): pass
|
||||
def record(self): self.start = time.perf_counter()
|
||||
def time_till(self, other): return self.start - other.start
|
||||
def time_till(self, other): return other.start - self.start
|
||||
def synchronize(self): pass
|
||||
class Context:
|
||||
synchronize = lambda:0 # noqa: E731
|
||||
|
|
Loading…
Reference in New Issue