2023-02-27 23:54:47 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import unittest
|
|
|
|
from tinygrad.tensor import Tensor, Device
|
|
|
|
from tinygrad.nn import Conv2d
|
2023-08-29 10:59:55 +08:00
|
|
|
from tinygrad.jit import CacheCollector
|
2023-07-24 04:00:56 +08:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
pytestmark = pytest.mark.webgpu
|
2023-02-27 23:54:47 +08:00
|
|
|
|
2023-03-02 23:49:19 +08:00
|
|
|
#@unittest.skipUnless(Device.DEFAULT == "GPU", "Only GPU supports cache")
|
|
|
|
@unittest.skip("with JIT changes, you only get the raw buffer")
|
2023-02-27 23:54:47 +08:00
|
|
|
class TestConvShapetracker(unittest.TestCase):
|
|
|
|
def test_conv_3x3_one_view(self):
|
|
|
|
inp = Tensor.randn(1,16,10,10).realize()
|
|
|
|
conv = Conv2d(16, 32, (3,3))
|
|
|
|
conv(inp).realize()
|
2023-08-29 10:59:55 +08:00
|
|
|
CacheCollector.start()
|
2023-02-27 23:54:47 +08:00
|
|
|
conv(inp).realize()
|
2023-08-29 10:59:55 +08:00
|
|
|
test = CacheCollector.finish()
|
2023-03-02 10:57:29 +08:00
|
|
|
assert len(test) == 1, f"conv should only have one kernel {[x[0].name for x in test]}"
|
|
|
|
print(test[0][0].prg)
|
2023-02-27 23:54:47 +08:00
|
|
|
for arg in test[0][1]:
|
|
|
|
print(arg.st)
|
|
|
|
assert len(arg.st.views) == 1
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|