mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-22 21:38:10 -05:00
* models matrix * fix typo and install gpu deps * install llvm deps if needed * fix * testops with cuda * remove pip cache since not work * cuda env * install cuda deps * maybe it will work now * i can't read * all tests in matrix * trim down more * opencl stuff in matrix * opencl pip cache * test split * change cuda test exclusion * test * fix cuda maybe * add models * add more n=auto * third thing * fix bug * cache pip more * change name * update tests * try again cause why not * balance * try again... * try apt cache for cuda * try on gpu: * try cuda again * update packages step * replace libz-dev with zlib1g-dev * only cache cuda * why error * fix gpuocelot bug * apt cache err * apt cache to slow? * opt and image in single runner * add a couple n=autos * remove test matrix * try cuda apt cache again * libz-dev -> zlib1g-dev * remove -s since not supported by xdist * the cache takes too long and doesn't work * combine webgpu and metal tests * combine imagenet to c and cpu tests * torch tests with linters * torch back by itself * small windows clang test with torch tests * fix a goofy windows bug * im dumb * bro * clang with linters * fix pylint error * linter not work on windows * try with clang again * clang and imagenet? * install deps * fix * fix quote * clang by itself (windows too slow) * env vars for imagenet * cache pip for metal and webgpu tests * try torch with metal and webgpu * doesn't work, too long * remove -v * try -n=logical * don't use logical * revert accidental thing * remove some prints unless CI * fix print unless CI * ignore speed tests for slow tests * clang windows in matrix (ubuntu being tested in imagenet->c test) * try manual pip cache * fix windows pip cache path * all manual pip cache * fix pip cache dir for macos * print_ci function in helpers * CI as variable, no print_ci * missed one * cuda tests with docker image * remove setup-python action for cuda * python->python3? * remove -s -v * try fix pip cache * maybe fix * try to fix pip cache * is this the path? * maybe cache pip * try again * create wheels dir * ? * cuda pip deps in dockerfile * disable pip cache for clang * image from ghcr instead of docker hub * why is clang like this * fast deps * try use different caches * remove the fast thing * try with lighter image * remove setup python for cuda * small docker and cuda fast deps * ignore a few more tests * cool docker thing (maybe) * oops * quotes * fix docker command * fix bug * ignore train efficientnet test * remove dockerfile (docker stuff takes too long) * remove docker stuff and normal cuda * oops * ignore the tests for cuda * does this work * ignore test_train on slow backends * add space * llvm ignore same tests as cuda * nvm * ignore lr scheduler tests * get some stats * fix ignore bug * remove extra ' * remove and * ignore test for llvm * change ignored tests and durationon all backends * fix * and -> or * ignore some more cuda tests * finally? * does this fix it * remove durations=0 * add some more tests to llvm * make last pytest more readable * fix * don't train efficientnet on cpu * try w/out pip cache * pip cache seems to be generally better * pytest file markers * try apt fast for cuda * use quick install for apt-fast * apt-fast not worth * apt-get to apt * fix typo * suppress warnings * register markers * disable debug on fuzz tests * change marker names * apt update and apt install in one command * update marker names in test.yml * webgpu pytest marker
57 lines
2.3 KiB
Python
57 lines
2.3 KiB
Python
import unittest
|
|
from tinygrad.tensor import Tensor
|
|
from tinygrad.helpers import dtypes
|
|
from tinygrad.lazy import Device
|
|
import pytest
|
|
# similar to test/external/external_test_gpu_ast.py, but universal
|
|
|
|
pytestmark = pytest.mark.exclude_cuda
|
|
|
|
class TestSpecific(unittest.TestCase):
|
|
# from openpilot
|
|
|
|
# 1x1 6 <- 24
|
|
def test_1x1_6_24(self):
|
|
x = Tensor.randn(1, 24*4, 32, 64)
|
|
w = Tensor.randn(6*4, 24*4, 1, 1)
|
|
x.conv2d(w).permute(0,2,3,1).reshape(32, 384, 4).contiguous().realize()
|
|
|
|
def test_vec_mul(self):
|
|
# this forces it to be an image...
|
|
x = Tensor.ones(1, 512, 4).contiguous().reshape(1, 2048)
|
|
w = Tensor.randn(2048, 512)
|
|
(x @ w).reshape(1, 128, 4).contiguous().realize()
|
|
|
|
@unittest.skipIf(Device.DEFAULT in ["LLVM", "WEBGPU"], "Broken on LLVM and webgpu")
|
|
def test_big_vec_mul(self):
|
|
# from LLaMA
|
|
# 0 buffer<4096, dtypes.float> [View((1024, 1, 1, 4), (4, 0, 0, 1), 0, None)]
|
|
# 1 buffer<4096, dtypes.float> [View((1024, 1024, 4, 4), (0, 4, 1, 0), 0, None)]
|
|
# 2 buffer<16777216, dtypes.half> [View((1024, 1024, 4, 4), (16384, 4, 1, 4096), 0, None)]
|
|
x = Tensor.randn(4096).realize()
|
|
w = Tensor.randn(4096, 4096, device='cpu').cast(dtypes.float16).to(Device.DEFAULT).realize()
|
|
(x @ w.T).realize()
|
|
|
|
# from https://dl.acm.org/doi/pdf/10.1145/3495243.3517020
|
|
|
|
# ~260 GFLOPS on Adreno 640, should be 260*(720/890)*(596/710) = 176.5 on downclocked 630
|
|
# we get 170
|
|
def test_1x1_28_28(self):
|
|
x = Tensor.randn(1, 256, 28, 28)
|
|
w = Tensor.randn(256, 256, 1, 1)
|
|
x.conv2d(w).permute(0,2,3,1).reshape(28, 28*256//4, 4).contiguous().realize()
|
|
|
|
# 132 GFLOPS on Adreno 640, should be 132*(720/890)*(596/710) = 90 on downclocked 630
|
|
# gets 54 with broken opt, 74 without opt, and 146 if we pad and opt 3!
|
|
def test_3x3_28_28_stride_2(self):
|
|
x = Tensor.randn(1, 288, 36, 36)
|
|
w = Tensor.randn(384, 288, 3, 3)
|
|
x.conv2d(w, stride=2).permute(0,2,3,1).reshape(17, 17*384//4, 4).contiguous().realize()
|
|
|
|
def test_3x3_28_28_stride_2_padded(self):
|
|
x = Tensor.randn(1, 288, 36, 36)
|
|
w = Tensor.randn(384, 288, 3, 3)
|
|
x.conv2d(w, stride=2, padding=1).permute(0,2,3,1).reshape(18, 18*384//4, 4).contiguous().realize()
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main() |