diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99d0cd2048..0ae74053fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -318,6 +318,9 @@ jobs: CLOUDDEV=CLANG CLOUD=1 python3 test/test_tiny.py CLOUDDEV=GPU CLOUD=1 python3 test/test_tiny.py CLOUDDEV=GPU IMAGE=2 CLOUD=1 python3 test/test_tiny.py + - if: ${{ matrix.task == 'onnx' }} + name: Test Optimization Helpers + run: PYTHONPATH="." DEBUG=1 python3 extra/optimization/test_helpers.py - if: ${{ matrix.task == 'onnx' }} name: Test Action Space run: PYTHONPATH="." DEBUG=1 GPU=1 python3 extra/optimization/get_action_space.py diff --git a/extra/optimization/helpers.py b/extra/optimization/helpers.py index 9dcaf8133c..c433359d6c 100644 --- a/extra/optimization/helpers.py +++ b/extra/optimization/helpers.py @@ -32,8 +32,8 @@ def load_worlds(filter_reduce=True, filter_noimage=True, filter_novariable=True) if DEBUG >= 1: print(f"loaded {len(ast_strs)=} before filters") if filter_reduce: ast_strs = [x for x in ast_strs if "REDUCE_AXIS" in x] if filter_noimage: ast_strs = [x for x in ast_strs if "dtypes.image" not in x] - if filter_novariable: ast_strs = [x for x in ast_strs if "Variable" not in x] - if DEBUG >= 1: print(f"loaded {len(ast_strs)=} after filters") + if filter_novariable: ast_strs = [x for x in ast_strs if "DEFINE_VAR" not in x] + if DEBUG >= 1: print(f"loaded {len(ast_strs)=} after filters {filter_reduce=}, {filter_noimage=}, {filter_novariable=}") random.seed(1337) random.shuffle(ast_strs) return ast_strs diff --git a/extra/optimization/test_helpers.py b/extra/optimization/test_helpers.py new file mode 100644 index 0000000000..bd11f3d712 --- /dev/null +++ b/extra/optimization/test_helpers.py @@ -0,0 +1,19 @@ +import unittest + +from extra.optimization.helpers import load_worlds + +class TestKernelDataset(unittest.TestCase): + def test_load_worlds_filters(self): + all_kernels = load_worlds(filter_reduce=False, filter_noimage=False, filter_novariable=False) + + reduce_kernels = load_worlds(filter_reduce=True, filter_noimage=False, filter_novariable=False) + self.assertGreater(len(all_kernels), len(reduce_kernels)) + + image_kernels = load_worlds(filter_reduce=False, filter_noimage=True, filter_novariable=False) + self.assertGreater(len(all_kernels), len(image_kernels)) + + variable_kernels = load_worlds(filter_reduce=False, filter_noimage=False, filter_novariable=True) + self.assertGreater(len(all_kernels), len(variable_kernels)) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file