From fbb4099b3c324e97362e66f76d8ef59fc7704f90 Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Tue, 19 Nov 2024 19:26:51 +0800 Subject: [PATCH] add test for compile3 [pr] (#7783) Co-authored-by: qazal <77887910+Qazalin@users.noreply.github.com> --- .github/workflows/test.yml | 3 +++ examples/openpilot/compile3.py | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e65939fdb..41992e219b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -300,6 +300,9 @@ jobs: - if: ${{ matrix.task == 'optimage' }} name: Test openpilot model correctness (float32) run: PYTHONPATH="." FLOAT16=0 DEBUGCL=1 GPU=1 IMAGE=2 python examples/openpilot/compile2.py + - if: ${{ matrix.task == 'optimage' }} + name: Test openpilot compile3 + run: PYTHONPATH="." FLOAT16=0 DEBUGCL=1 GPU=1 IMAGE=2 python examples/openpilot/compile3.py - if: ${{ matrix.task == 'optimage' }} name: Test openpilot alt model correctness (float32) run: PYTHONPATH="." FLOAT16=0 DEBUGCL=1 GPU=1 IMAGE=2 python examples/openpilot/compile2.py https://github.com/commaai/openpilot/raw/3799fe46b3a629e491d4b8498b8ae83e4c88c304/selfdrive/modeld/models/supercombo.onnx diff --git a/examples/openpilot/compile3.py b/examples/openpilot/compile3.py index 74afadfc14..87776e777c 100644 --- a/examples/openpilot/compile3.py +++ b/examples/openpilot/compile3.py @@ -27,6 +27,7 @@ def compile(): input_shapes = {inp.name:tuple(x.dim_value for x in inp.type.tensor_type.shape.dim) for inp in onnx_model.graph.input} input_types = {inp.name: tensor_dtype_to_np_dtype(inp.type.tensor_type.elem_type) for inp in onnx_model.graph.input} + if getenv("FLOAT16", 0) == 0: input_types = {k:(np.float32 if v==np.float16 else v) for k,v in input_types.items()} Tensor.manual_seed(100) new_inputs = {k:Tensor.randn(*shp, dtype=_from_np_dtype(input_types[k])).mul(8).realize() for k,shp in sorted(input_shapes.items())} print("created tensors")