diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 699e40be6a..52d68c8fcc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -295,7 +295,7 @@ jobs: - if: ${{ matrix.task == 'optimage' }} name: Test openpilot model kernel count and gate usage run: | - PYTHONPATH="." ALLOWED_KERNEL_COUNT=208 ALLOWED_GATED_READ_IMAGE=13 FLOAT16=0 GPU=1 IMAGE=2 python examples/openpilot/compile3.py https://github.com/commaai/openpilot/raw/v0.9.4/selfdrive/modeld/models/supercombo.onnx + PYTHONPATH="." ALLOWED_KERNEL_COUNT=208 ALLOWED_READ_IMAGE=2131 ALLOWED_GATED_READ_IMAGE=13 FLOAT16=0 GPU=1 IMAGE=2 python examples/openpilot/compile3.py https://github.com/commaai/openpilot/raw/v0.9.4/selfdrive/modeld/models/supercombo.onnx - if: ${{ matrix.task == 'optimage' }} name: Test openpilot alt model correctness (float32) run: PYTHONPATH="." FLOAT16=0 DEBUGCL=1 GPU=1 IMAGE=2 python examples/openpilot/compile3.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 47ca0a41b2..973ddcc819 100644 --- a/examples/openpilot/compile3.py +++ b/examples/openpilot/compile3.py @@ -50,16 +50,20 @@ def compile(onnx_file): # checks from compile2 kernel_count = 0 + read_image_count = 0 gated_read_image_count = 0 for ei in run_onnx_jit.captured.jit_cache: if isinstance(ei.prg, CompiledRunner): kernel_count += 1 + read_image_count += ei.prg.p.src.count("read_image") gated_read_image_count += ei.prg.p.src.count("?read_image") - print(f"kernel_count: {kernel_count} gated_read_image_count: {gated_read_image_count}") - assert kernel_count <= getenv("ALLOWED_KERNEL_COUNT", 0) or getenv("ALLOWED_KERNEL_COUNT", 0) == 0, "too many kernels!" + print(f"{kernel_count=}, {read_image_count=}, {gated_read_image_count=}") + if (allowed_kernel_count:=getenv("ALLOWED_KERNEL_COUNT", -1)) != -1: + assert kernel_count <= allowed_kernel_count, f"too many kernels! {kernel_count=}, {allowed_kernel_count=}" + if (allowed_read_image:=getenv("ALLOWED_READ_IMAGE", -1)) != -1: + assert read_image_count == allowed_read_image, f"different read_image! {read_image_count=}, {allowed_read_image=}" if (allowed_gated_read_image:=getenv("ALLOWED_GATED_READ_IMAGE", -1)) != -1: - assert gated_read_image_count <= allowed_gated_read_image, \ - f"too many gated read_image! {gated_read_image_count=}, {allowed_gated_read_image=}" + assert gated_read_image_count <= allowed_gated_read_image, f"too many gated read_image! {gated_read_image_count=}, {allowed_gated_read_image=}" with open(OUTPUT, "wb") as f: pickle.dump(run_onnx_jit, f)