From 8919ca8163c0fc59f0d0c6226c10597b1a67673b Mon Sep 17 00:00:00 2001 From: George Hotz Date: Fri, 3 Mar 2023 06:36:06 -0800 Subject: [PATCH] test cleanups --- test/{ => external}/external_osx_profiling.py | 0 test/{ => external}/external_test_gpu_ast.py | 0 test/{ => external}/external_test_image.py | 0 test/{ => external}/external_test_llvm.py | 0 test/{ => external}/external_test_onnx_backend.py | 0 test/{ => external}/external_test_opt.py | 0 test/{ => external}/external_test_yolo.py | 0 test/{ => external}/graph_batchnorm.py | 0 test/{ => models}/efficientnet/Chicken.jpg | Bin test/{ => models}/efficientnet/car.jpg | Bin .../efficientnet/imagenet1000_clsidx_to_labels.txt | 0 test/{ => models}/test_efficientnet.py | 1 + test/{ => models}/test_mnist.py | 0 test/{ => models}/test_onnx.py | 2 +- test/{ => models}/test_train.py | 0 test/test_speed_v_torch.py | 3 --- test/{ => unit}/test_graph.py | 0 test/{ => unit}/test_shapetracker.py | 8 ++++---- test/{ => unit}/test_symbolic.py | 0 test/{ => unit}/test_utils.py | 0 20 files changed, 6 insertions(+), 8 deletions(-) rename test/{ => external}/external_osx_profiling.py (100%) rename test/{ => external}/external_test_gpu_ast.py (100%) rename test/{ => external}/external_test_image.py (100%) rename test/{ => external}/external_test_llvm.py (100%) rename test/{ => external}/external_test_onnx_backend.py (100%) rename test/{ => external}/external_test_opt.py (100%) rename test/{ => external}/external_test_yolo.py (100%) rename test/{ => external}/graph_batchnorm.py (100%) rename test/{ => models}/efficientnet/Chicken.jpg (100%) rename test/{ => models}/efficientnet/car.jpg (100%) rename test/{ => models}/efficientnet/imagenet1000_clsidx_to_labels.txt (100%) rename test/{ => models}/test_efficientnet.py (98%) rename test/{ => models}/test_mnist.py (100%) rename test/{ => models}/test_onnx.py (98%) rename test/{ => models}/test_train.py (100%) rename test/{ => unit}/test_graph.py (100%) rename test/{ => unit}/test_shapetracker.py (98%) rename test/{ => unit}/test_symbolic.py (100%) rename test/{ => unit}/test_utils.py (100%) diff --git a/test/external_osx_profiling.py b/test/external/external_osx_profiling.py similarity index 100% rename from test/external_osx_profiling.py rename to test/external/external_osx_profiling.py diff --git a/test/external_test_gpu_ast.py b/test/external/external_test_gpu_ast.py similarity index 100% rename from test/external_test_gpu_ast.py rename to test/external/external_test_gpu_ast.py diff --git a/test/external_test_image.py b/test/external/external_test_image.py similarity index 100% rename from test/external_test_image.py rename to test/external/external_test_image.py diff --git a/test/external_test_llvm.py b/test/external/external_test_llvm.py similarity index 100% rename from test/external_test_llvm.py rename to test/external/external_test_llvm.py diff --git a/test/external_test_onnx_backend.py b/test/external/external_test_onnx_backend.py similarity index 100% rename from test/external_test_onnx_backend.py rename to test/external/external_test_onnx_backend.py diff --git a/test/external_test_opt.py b/test/external/external_test_opt.py similarity index 100% rename from test/external_test_opt.py rename to test/external/external_test_opt.py diff --git a/test/external_test_yolo.py b/test/external/external_test_yolo.py similarity index 100% rename from test/external_test_yolo.py rename to test/external/external_test_yolo.py diff --git a/test/graph_batchnorm.py b/test/external/graph_batchnorm.py similarity index 100% rename from test/graph_batchnorm.py rename to test/external/graph_batchnorm.py diff --git a/test/efficientnet/Chicken.jpg b/test/models/efficientnet/Chicken.jpg similarity index 100% rename from test/efficientnet/Chicken.jpg rename to test/models/efficientnet/Chicken.jpg diff --git a/test/efficientnet/car.jpg b/test/models/efficientnet/car.jpg similarity index 100% rename from test/efficientnet/car.jpg rename to test/models/efficientnet/car.jpg diff --git a/test/efficientnet/imagenet1000_clsidx_to_labels.txt b/test/models/efficientnet/imagenet1000_clsidx_to_labels.txt similarity index 100% rename from test/efficientnet/imagenet1000_clsidx_to_labels.txt rename to test/models/efficientnet/imagenet1000_clsidx_to_labels.txt diff --git a/test/test_efficientnet.py b/test/models/test_efficientnet.py similarity index 98% rename from test/test_efficientnet.py rename to test/models/test_efficientnet.py index 7ab64953..fcee5a05 100644 --- a/test/test_efficientnet.py +++ b/test/models/test_efficientnet.py @@ -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) diff --git a/test/test_mnist.py b/test/models/test_mnist.py similarity index 100% rename from test/test_mnist.py rename to test/models/test_mnist.py diff --git a/test/test_onnx.py b/test/models/test_onnx.py similarity index 98% rename from test/test_onnx.py rename to test/models/test_onnx.py index 47cc40c8..43279540 100644 --- a/test/test_onnx.py +++ b/test/models/test_onnx.py @@ -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): diff --git a/test/test_train.py b/test/models/test_train.py similarity index 100% rename from test/test_train.py rename to test/models/test_train.py diff --git a/test/test_speed_v_torch.py b/test/test_speed_v_torch.py index b0dafbd0..b5504b3c 100644 --- a/test/test_speed_v_torch.py +++ b/test/test_speed_v_torch.py @@ -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") diff --git a/test/test_graph.py b/test/unit/test_graph.py similarity index 100% rename from test/test_graph.py rename to test/unit/test_graph.py diff --git a/test/test_shapetracker.py b/test/unit/test_shapetracker.py similarity index 98% rename from test/test_shapetracker.py rename to test/unit/test_shapetracker.py index bf9ffa10..51129517 100644 --- a/test/test_shapetracker.py +++ b/test/unit/test_shapetracker.py @@ -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): diff --git a/test/test_symbolic.py b/test/unit/test_symbolic.py similarity index 100% rename from test/test_symbolic.py rename to test/unit/test_symbolic.py diff --git a/test/test_utils.py b/test/unit/test_utils.py similarity index 100% rename from test/test_utils.py rename to test/unit/test_utils.py