mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-10 07:28:15 -05:00
* lazy rewrite, try 2 * min fix tests * pass contig test * put broken pads back * move that to realize * no contig child fixes array packing * so wrong * now that's correct * base children * fix bind issues * disable to_image_idx * fix tests * that failure shouldn't break other tests * more fixes * fix torch * skip failing tests in CI * 1e-7 * half is broken * 1e-6 margin of error
26 lines
787 B
Python
26 lines
787 B
Python
import unittest
|
|
import numpy as np
|
|
from tinygrad import Tensor, dtypes
|
|
from tinygrad.lazy import create_schedule
|
|
from tinygrad.realize import run_schedule
|
|
|
|
class TestFusionOp(unittest.TestCase):
|
|
def test_contiguous_add(self):
|
|
def test(contig=False):
|
|
bt = Tensor(np.arange(16), dtype=dtypes.float32).reshape(4,4)
|
|
x = bt.permute(1,0)
|
|
if contig: x = x.contiguous()
|
|
return (x.permute(1,0) + bt).data()
|
|
assert test() == test(True)
|
|
|
|
def test_expand_fuse(self):
|
|
bt = Tensor(np.ones((10, 1)), dtype=dtypes.float32)
|
|
out = (bt*2).expand(10,10).sum(1)
|
|
sched = create_schedule([out.lazydata], None)
|
|
run_schedule(sched)
|
|
outd = out.data().tolist()
|
|
assert all(x == 20.0 for x in outd)
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main(verbosity=2)
|