Skip to content

Add ONNX CPU benchmarking#5

Open
leeclemnet wants to merge 3 commits intomainfrom
feat/onnx-cpu-inference
Open

Add ONNX CPU benchmarking#5
leeclemnet wants to merge 3 commits intomainfrom
feat/onnx-cpu-inference

Conversation

@leeclemnet
Copy link
Copy Markdown

@leeclemnet leeclemnet commented Mar 24, 2026

What does this PR do?

Adds SAB support for ONNX CPU execution provider. This is useful for edge device profiling and particularly for benchmarking CPU-optimized models like YOLOLite-Edge variants.

  • Extracted ProfilerBase in profiler.py, added CPUProfiler — uses time.perf_counter_ns() for wall-clock timing on CPU
  • Refactored ONNXInference into ONNXInferenceBase → ONNXInferenceCUDA / ONNXInferenceCPU in onnx_inference.py
  • Updated pretty_print_results() — runtime column shows ONNX-CPU / ONNX-CUDA / TRT
  • Added is_cpu to dump() output for result serialization
  • Added RFDETRONNXCPUInference in benchmark_rfdetr.py with CPU benchmark requests for nano, small, and medium variants (grouped after TRT requests per model size)
  • Add ONNXInference warmup step and fix intra/inter_op thread count for stable CPU inference timing

Type of Change

  • New feature (non-breaking change that adds functionality)

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Test details:

Tested benchmark_rfdetr.py against RF100 aquarium test set on n1-standard-16 VM + T4.

python -m sab.models.benchmark_rfdetr rf100/aquarium-qlnqy/test rf100/aquarium-qlnqy/test/_annotations.coco.json
Model                          Runtime  FP16   mAP50  mAP50-95   AP75   Latency Throttled
-----------------------------------------------------------------------------------------
rf-detr-nano.onnx              TRT      no       4.7       3.2    3.4      9.84       yes
rf-detr-nano.onnx              TRT      yes      4.9       3.3    3.6      2.36        no
rf-detr-nano.onnx              ONNX-CPU no       4.7       3.2    3.4     99.99        no
rf-detr-small.onnx             TRT      no       3.4       2.5    2.9     18.99       yes
rf-detr-small.onnx             TRT      yes      3.5       2.6    2.9      3.60       yes
rf-detr-small.onnx             ONNX-CPU no       3.4       2.5    2.9    177.84        no
rf-detr-medium.onnx            TRT      no       6.2       4.8    5.4     25.88       yes
rf-detr-medium.onnx            TRT      yes      6.1       4.7    5.5      4.65       yes
rf-detr-medium.onnx            ONNX-CPU no       6.2       4.7    5.3    233.72        no

AP breakdown (COCO):
Model                            AP_s   AP_m   AP_l
---------------------------------------------------
rf-detr-nano.onnx                 0.1    1.3    4.6
rf-detr-nano.onnx                 0.2    1.3    4.8
rf-detr-nano.onnx                 0.1    1.3    4.6
rf-detr-small.onnx                0.1    1.1    3.8
rf-detr-small.onnx                0.1    1.2    3.8
rf-detr-small.onnx                0.1    1.1    3.8
rf-detr-medium.onnx               0.3    4.4    6.7
rf-detr-medium.onnx               0.3    4.4    6.5
rf-detr-medium.onnx               0.3    4.3    6.7

AR breakdown (COCO):
Model                            AR@1  AR@10   AR@max_dets   AR_s   AR_m   AR_l
-------------------------------------------------------------------------------
rf-detr-nano.onnx                 4.2   11.1          13.7    4.2   10.1   20.1
rf-detr-nano.onnx                 4.2   12.1          14.7    4.6   10.1   22.1
rf-detr-nano.onnx                 4.2   11.1          13.7    4.2   10.1   20.1
rf-detr-small.onnx                5.0   12.0          14.6    3.9    8.4   23.1
rf-detr-small.onnx                5.0   12.1          14.5    3.9    8.3   22.4
rf-detr-small.onnx                5.0   12.0          14.6    3.9    8.4   23.1
rf-detr-medium.onnx               6.4   18.0          20.6    5.4   15.9   28.8
rf-detr-medium.onnx               6.0   18.0          20.6    5.3   16.2   26.7
rf-detr-medium.onnx               6.4   17.7          20.2    5.4   15.1   28.8

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context

@leeclemnet leeclemnet force-pushed the feat/onnx-cpu-inference branch from 81b113c to 9b1cd55 Compare March 24, 2026 14:20
@leeclemnet leeclemnet marked this pull request as ready for review March 24, 2026 14:31
@leeclemnet leeclemnet marked this pull request as draft March 24, 2026 14:34
@leeclemnet leeclemnet force-pushed the feat/onnx-cpu-inference branch from 9b1cd55 to de0ef52 Compare March 24, 2026 14:42
@leeclemnet leeclemnet marked this pull request as ready for review March 24, 2026 14:49
@leeclemnet leeclemnet requested a review from isaacrob March 24, 2026 14:49
@leeclemnet leeclemnet force-pushed the feat/onnx-cpu-inference branch from 1800d13 to de0ef52 Compare March 24, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant