Files
tinygrad/test/test_kernel_cache.py
George Hotz 56f44bd10e move the compiler cache to be global (#2957)
* move the compiler cache to be global

* remove non robust test

* remove dead code
2024-01-01 10:59:56 -08:00

28 lines
697 B
Python

#!/usr/bin/env python
import unittest
from tinygrad.tensor import Tensor
from tinygrad import Device
class TestKernelCache(unittest.TestCase):
def test_kernel_cache_in_action(self):
if Device.DEFAULT not in ["CLANG"]:
self.skipTest("No custom kernel cache is implemented")
a = Tensor.rand(4,4)
b = Tensor.rand(4,4)
x = a + b
x.realize()
orig_compile_func = Device['CLANG'].compiler
Device['CLANG'].compiler = None # making it not callable
a1 = Tensor.rand(4,4)
b1 = Tensor.rand(4,4)
x1 = a1 + b1
x1.realize() # Same kernel should be from cache.
Device['CLANG'].compiler = orig_compile_func
if __name__ == "__main__":
unittest.main()