test cleanups

This commit is contained in:
George Hotz 2023-03-03 06:36:06 -08:00
parent 459488bba2
commit 8919ca8163
20 changed files with 6 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -42,6 +42,7 @@ def preprocess(img, new=False):
def _infer(model: EfficientNet, img, bs=1):
Tensor.training = False
img = preprocess(img)
# run the net
if bs > 1: img = img.repeat(bs, axis=0)

View File

@ -111,7 +111,7 @@ class TestOnnxModel(unittest.TestCase):
def _test_model(self, dat, input_name, input_new, debug=False):
onnx_model = onnx.load(io.BytesIO(dat))
print("onnx loaded")
from test.test_efficientnet import chicken_img, car_img, preprocess, _LABELS
from test.models.test_efficientnet import chicken_img, car_img, preprocess, _LABELS
run_onnx = get_run_onnx(onnx_model)
def run(img):

View File

@ -42,9 +42,6 @@ def helper_test_speed(f1, *args):
# force syncing
[x.numpy() if isinstance(x, Tensor) or str(torch_device) == "cpu" else x.cpu().numpy() for x in args if x is not None]
# L2 defeat (64 MB)
np.zeros((4096, 4096), dtype=np.float32) - 1
GlobalCounters.global_ops = 0
GlobalCounters.global_mem = 0
if DEBUG >= 4: print("benchmark start")

View File

@ -10,7 +10,7 @@ def shapetracker_getitem(st, val):
exec(f"valid={valid.render()};idx={idx.render()}", None, locals)
return locals["idx"] if locals["valid"] else -1
class TestingShapeTracker:
class CheckingShapeTracker:
def __init__(self, shape):
self.st = ShapeTracker(shape)
self.t = np.arange(prod(shape), dtype=np.uint8).reshape(shape)
@ -93,7 +93,7 @@ class TestImageShapeTracker(unittest.TestCase):
class TestSimplifyingShapeTracker(unittest.TestCase):
def setUp(self):
self.st = TestingShapeTracker((1, 10))
self.st = CheckingShapeTracker((1, 10))
def tearDown(self):
self.st.assert_same()
@ -236,7 +236,7 @@ class TestComplexShapeTracker(unittest.TestCase):
class TestSingleShapeTracker(unittest.TestCase):
def setUp(self):
self.st = TestingShapeTracker((7,4))
self.st = CheckingShapeTracker((7,4))
def tearDown(self):
self.st.assert_same()
@ -275,7 +275,7 @@ class TestSingleShapeTracker(unittest.TestCase):
class TestShapeTracker(unittest.TestCase):
def setUp(self):
self.st = TestingShapeTracker((7,4))
self.st = CheckingShapeTracker((7,4))
self.apply = lambda fxn: [fxn(x) for x in [self.st]]
def tearDown(self):