carrot/tinygrad_repo/test/unit/test_kernelize.py
carrot 9c7833faf9
KerryGold Model, AGNOS12.4, AdjustLaneChange, EnglighSound (#182)
* Vegetarian Filet o Fish model

* fix.. atc..

* test cluster_speed_limit

* fix.. cluster_speed_limit.. 2

* fix.. clusterspeedlimit3

* cruise speed to roadlimit speed

* fix..

* fix.. eng

* deltaUp/Down for lanechange

* fix.. atc desire...

* fix..

* ff

* ff

* fix..

* fix.. eng

* fix engsound

* Update desire_helper.py

* fix.. connect...

* fix curve_min speed

* Revert "fix curve_min speed"

This reverts commit fcc9c2eb14eb3504abef3e420db93e8882e56f37.

* Reapply "fix curve_min speed"

This reverts commit 2d2bba476c58a7b4e13bac3c3ad0e4694c95515d.

* fix.. auto speed up.. roadlimit

* fix.. atc auto lanechange...

* Update desire_helper.py

* Update cruise.py

* debug atc...

* fix.. waze alert offset..

* fix..

* test atc..

* fix..

* fix.. atc

* atc test..

* fix.. atc

* fix.. atc2

* fix.. atc3

* KerryGold Model.  latsmooth_sec = 0.0

* lat smooth seconds 0.13

* fix comment

* fix.. auto cruise, and speed unit

* change lanemode switching.

* erase mazda lkas button.
2025-06-22 10:51:42 +09:00

34 lines
1021 B
Python

import unittest
from tinygrad import Tensor
from tinygrad.uop import Ops
class TestKernelize(unittest.TestCase):
def test_add_reshaped(self):
a = Tensor.ones(16,16).contiguous()
b = Tensor.zeros(16,16).contiguous()
ret = (a+b).sum(axis=1)
ret_reshaped_1 = ret.reshape(4,4)
ret_reshaped_2 = ret.reshape(2,8)
ret.kernelize()
self.assertIs(ret_reshaped_1.uop.src[0], ret_reshaped_2.uop.src[0])
def test_two_reduce(self):
a = Tensor.ones(16,16).contiguous()
a1 = a.sum(axis=1)
a0 = a1.sum(axis=0)
a0.kernelize()
self.assertIs(a1.uop.base.op, Ops.ASSIGN)
def test_two_reduce_w_add(self):
a = Tensor.ones(16,16).contiguous()
a1 = a.sum(axis=1)
a0 = (a1+1).sum(axis=0)
a0.kernelize()
# NOTE: the +1 is fused with a1, so a1 is not kernelized
self.assertIs(a1.uop.base.op, Ops.REDUCE_AXIS)
# the input to the REDUCE_AXIS is an ASSIGN though
self.assertIs(a1.uop.base.src[0].base.op, Ops.ASSIGN)
if __name__ == '__main__':
unittest.main()