Commit 74403e2
authored
Add Android benchmark script (#18802)
### Summary
Add a new script to easily benchmark models on Android. It handles
building the runner, pushing the runner and model to the device via adb,
running the benchmark, cleaning up, and then summarizing the results.
Usage:
```
# ./devtools/scripts/benchmark_android.sh <model.pte> [options]
#
# Options:
# --warmup <N> Number of warmup executions (default: 1)
# --iterations <N> Number of timed executions (default: 10)
# --num-threads <N> CPU threads for inference (default: -1, auto-detect)
# --method <name> Method to run (default: first method in the program)
# --backends <list> Comma-separated backends (default: xnnpack)
# Supported: xnnpack, vulkan, qnn
# --device <serial> ADB device serial (for multiple devices)
# --etdump Enable event tracer and pull etdump back to host
# --no-cleanup Leave model file on device after benchmarking
# --rebuild Force cmake reconfigure and rebuild
# --build-dir <path> Reuse existing build directory (skip build step)
```
Example output:
```
executor_runner already built, skipping build. Use --rebuild to force.
Pushing files to device...
cmake-out-android-benchmark/executor_runner: 0 files pushed, 1 skipped.
/Users/gjcomer/models/yolo11n_xnnpack.pte: 1 file pushed, 0 skipped. 37.3 MB/s (10696000 bytes in 0.273s)
Running 1 warmup iteration(s)...
Running 10 benchmark iteration(s)...
Cleaning up model on device...
=========================================
Benchmark Results
=========================================
Model: yolo11n_xnnpack.pte
Warmup: 1 iteration(s)
Load: 39.258 ms
Benchmark: 10 iteration(s) in 952.097 ms
Average: 95.209 ms/iteration
Min: 87.583 ms
Max: 142.932 ms
=========================================
```
I also made a few small changes to examples/portable/executor_runner:
* Allow specifying the method name
* Log load time
* Log per-iteration time
* Add an option to enable/disable tensor output printing
cc @Gasoonjia1 parent 5e8a0df commit 74403e2
File tree
2 files changed
+475
-10
lines changed- devtools/scripts
- examples/portable/executor_runner
2 files changed
+475
-10
lines changed
0 commit comments