fix a few tests [pr] (#13498)

This commit is contained in:
George Hotz
2025-11-29 13:43:45 -08:00
committed by GitHub
parent 29b11c8992
commit fd373fea7a
4 changed files with 18 additions and 16 deletions

View File

@@ -1,10 +1,8 @@
import unittest
import numpy as np
from tinygrad import Device
from tinygrad.device import CompileError
from tinygrad.helpers import flat_mv
if Device.DEFAULT=="AMD":
from tinygrad.runtime.ops_amd import AMDAllocator, AMDDevice, AMDProgram
if Device.DEFAULT == "AMD":
# NOTE: if you don't gate this, LVP fails on Mac
from tinygrad.runtime.support.compiler_amd import AMDLLVMCompiler
@unittest.skipUnless(Device.DEFAULT == "AMD", "Runs only on AMD")
@@ -18,16 +16,8 @@ entry:
ret void
}
'''
device = AMDDevice()
compiler = AMDLLVMCompiler("gfx1100")
obj = compiler.compile(src)
allocator = AMDAllocator(device)
a = allocator.alloc(1*8)
prog = AMDProgram(device, "test", obj)
prog(a, wait=True)
na = np.empty(1, np.uint64)
allocator._copyout(flat_mv(na.data), a)
assert na == [0x1234567800000005]
compiler.compile(src)
def test_compiler_diag_error(self):
src = """

View File

@@ -224,7 +224,8 @@ class TestHCQ(unittest.TestCase):
def test_copy_64bit(self):
if TestHCQ.d0.hw_copy_queue_t is None: self.skipTest("device does not support copy queue")
for sz in [(1 << 32) - 1, (1 << 32), (1 << 32) + 1, (5 << 30), (6 << 30) - 0x4642ee1]:
# NOTE: these must be a multiple of 8 for .view(fmt='Q') to work
for sz in [(1 << 32) - 8, (1 << 32), (1 << 32) + 8, (5 << 30), (6 << 30) - 0x4642ee0]:
buf1 = Buffer(Device.DEFAULT, sz, dtypes.int8, options=BufferSpec(nolru=True)).ensure_allocated()
buf2 = Buffer(Device.DEFAULT, sz, dtypes.int8, options=BufferSpec(host=True, nolru=True)).ensure_allocated()

View File

@@ -94,12 +94,14 @@ class TestWhisper(unittest.TestCase):
self.assertEqual(TRANSCRIPTION_2, transcriptions[0])
self.assertEqual(TRANSCRIPTION_1, transcriptions[1])
@unittest.skip("file 3 url is broken")
@unittest.skipIf(CI or (Device.DEFAULT == "CPU" and CPU_LLVM), "too long for CI")
def test_transcribe_long(self):
waveform = [load_file_waveform(fetch(TEST_FILE_3_URL))]
transcription = transcribe_waveform(self.model, self.enc, waveform)
self.assertWER(transcription, TRANSCRIPTION_3, 0.085)
@unittest.skip("file 3 url is broken")
@unittest.skipIf(CI or (Device.DEFAULT == "CPU" and CPU_LLVM), "too long for CI")
def test_transcribe_long_no_batch(self):
waveforms = [load_file_waveform(fetch(TEST_FILE_3_URL)), load_file_waveform(TEST_FILE_1)]

View File

@@ -7,13 +7,22 @@ from tinygrad.engine.realize import run_schedule
from tinygrad.uop.ops import UOp
from tinygrad.tensor import Tensor
def _allocations_of_type(t):
ret = 0
for x in gc.get_objects():
try:
if isinstance(x, t): ret += 1
except ReferenceError:
pass
return ret
def tensors_allocated():
gc.collect()
return sum([isinstance(x, Tensor) for x in gc.get_objects()])
return _allocations_of_type(Tensor)
def bufs_allocated():
gc.collect()
return sum([isinstance(x, Buffer) for x in gc.get_objects()])
return _allocations_of_type(Buffer)
class TestGC(unittest.TestCase):