Skip to content

Add benchmarking script (#20188)#20188

Merged
metascroy merged 1 commit into
pytorch:mainfrom
metascroy:export-D108048181
Jun 10, 2026
Merged

Add benchmarking script (#20188)#20188
metascroy merged 1 commit into
pytorch:mainfrom
metascroy:export-D108048181

Conversation

@metascroy

@metascroy metascroy commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary:

Adds a standalone microbenchmark for the ImageProcessor reuse APIs and a companion script to diff two runs, so kernel/pipeline changes (e.g. the NEON deinterleave switch) can be measured reproducibly.

New directory xplat/executorch/extension/image/benchmark/:

  • image_processor_benchmark.cpp (cxx_binary) — times process_into (BGRA/RGBA) and process_yuv_into (NV12/NV21) over a sweep of common input sizes × target sizes. Per cell it runs variants covering execution path (CPU / GPU / size-default), resize mode (stretch / letterbox), orientation (upright + 90°), cropped ROI, and the allocating process() vs process_into(). Each row reports mean/median/p95/stddev over 100 iters (10 warmup) on a synthetic gradient input; a row that fails is reported as ERROR rather than timed.
    • Flags (all optional): --format=bgra|rgba|nv12|nv21, --unit=cpu|gpu|default (both default to all), --out=PATH (writes a clean results table; the input-size sweep and rotation always run). Output is grouped under === API-section banners with a column legend, and --- per-cell separators.
  • compare_benchmarks.py (python_binary, stdlib-only) — matches rows by (API section, input→target cell, variant) and prints per-row base / new speedup plus a summary bucketed by execution path (CPU / GPU / default).
  • README.md — usage, the build-mode caveat, and the capture→compare workflow.
  • BUCK / TARGETS / targets.bzl — build defs.

Note: benchmark only with an optimized build (-c cxx.extra_cxxflags=-Os); the default buck2 run is -O0 and unrepresentative.

Differential Revision: D108048181

@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20188

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 9 Pending, 1 Unrelated Failure

As of commit ea24622 with merge base 4519036 (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 10, 2026
@meta-codesync

meta-codesync Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@metascroy has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108048181.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync meta-codesync Bot changed the title Add benchmarking script Add benchmarking script (#20188) Jun 10, 2026
metascroy added a commit to metascroy/executorch that referenced this pull request Jun 10, 2026
Summary:

Adds a standalone microbenchmark for the ImageProcessor reuse APIs and a companion script to diff two runs, so kernel/pipeline changes (e.g. the NEON deinterleave switch) can be measured reproducibly.

New directory xplat/executorch/extension/image/benchmark/:

* image_processor_benchmark.cpp (cxx_binary) — times process_into (BGRA/RGBA) and process_yuv_into (NV12/NV21) over a sweep of common input sizes × target sizes. Per cell it runs variants covering execution path (CPU / GPU / size-default), resize mode (stretch / letterbox), orientation (upright + 90°), cropped ROI, and the allocating process() vs process_into(). Each row reports mean/median/p95/stddev over 100 iters (10 warmup) on a synthetic gradient input; a row that fails is reported as ERROR rather than timed.
    * Flags (all optional): --format=bgra|rgba|nv12|nv21, --unit=cpu|gpu|default (both default to all), --out=PATH (writes a clean results table; the input-size sweep and rotation always run). Output is grouped under === API-section banners with a column legend, and --- per-cell separators.
* compare_benchmarks.py (python_binary, stdlib-only) — matches rows by (API section, input→target cell, variant) and prints per-row base / new speedup plus a summary bucketed by execution path (CPU / GPU / default).
* README.md — usage, the build-mode caveat, and the capture→compare workflow.
* BUCK / TARGETS / targets.bzl — build defs.

Note: benchmark only with an optimized build (-c cxx.extra_cxxflags=-Os); the default buck2 run is -O0 and unrepresentative.

Differential Revision: D108048181
@metascroy metascroy force-pushed the export-D108048181 branch from 257df08 to 9f42724 Compare June 10, 2026 18:07
metascroy added a commit to metascroy/executorch that referenced this pull request Jun 10, 2026
Summary:

Adds a standalone microbenchmark for the ImageProcessor reuse APIs and a companion script to diff two runs, so kernel/pipeline changes (e.g. the NEON deinterleave switch) can be measured reproducibly.

New directory xplat/executorch/extension/image/benchmark/:

* image_processor_benchmark.cpp (cxx_binary) — times process_into (BGRA/RGBA) and process_yuv_into (NV12/NV21) over a sweep of common input sizes × target sizes. Per cell it runs variants covering execution path (CPU / GPU / size-default), resize mode (stretch / letterbox), orientation (upright + 90°), cropped ROI, and the allocating process() vs process_into(). Each row reports mean/median/p95/stddev over 100 iters (10 warmup) on a synthetic gradient input; a row that fails is reported as ERROR rather than timed.
    * Flags (all optional): --format=bgra|rgba|nv12|nv21, --unit=cpu|gpu|default (both default to all), --out=PATH (writes a clean results table; the input-size sweep and rotation always run). Output is grouped under === API-section banners with a column legend, and --- per-cell separators.
* compare_benchmarks.py (python_binary, stdlib-only) — matches rows by (API section, input→target cell, variant) and prints per-row base / new speedup plus a summary bucketed by execution path (CPU / GPU / default).
* README.md — usage, the build-mode caveat, and the capture→compare workflow.
* BUCK / TARGETS / targets.bzl — build defs.

Note: benchmark only with an optimized build (-c cxx.extra_cxxflags=-Os); the default buck2 run is -O0 and unrepresentative.

Differential Revision: D108048181
@metascroy metascroy force-pushed the export-D108048181 branch from 9f42724 to 803f6d3 Compare June 10, 2026 18:14
Summary:

Adds a standalone microbenchmark for the ImageProcessor reuse APIs and a companion script to diff two runs, so kernel/pipeline changes (e.g. the NEON deinterleave switch) can be measured reproducibly.

New directory xplat/executorch/extension/image/benchmark/:

* image_processor_benchmark.cpp (cxx_binary) — times process_into (BGRA/RGBA) and process_yuv_into (NV12/NV21) over a sweep of common input sizes × target sizes. Per cell it runs variants covering execution path (CPU / GPU / size-default), resize mode (stretch / letterbox), orientation (upright + 90°), cropped ROI, and the allocating process() vs process_into(). Each row reports mean/median/p95/stddev over 100 iters (10 warmup) on a synthetic gradient input; a row that fails is reported as ERROR rather than timed.
    * Flags (all optional): --format=bgra|rgba|nv12|nv21, --unit=cpu|gpu|default (both default to all), --out=PATH (writes a clean results table; the input-size sweep and rotation always run). Output is grouped under === API-section banners with a column legend, and --- per-cell separators.
* compare_benchmarks.py (python_binary, stdlib-only) — matches rows by (API section, input→target cell, variant) and prints per-row base / new speedup plus a summary bucketed by execution path (CPU / GPU / default).
* README.md — usage, the build-mode caveat, and the capture→compare workflow.
* BUCK / TARGETS / targets.bzl — build defs.

Note: benchmark only with an optimized build (-c cxx.extra_cxxflags=-Os); the default buck2 run is -O0 and unrepresentative.

Differential Revision: D108048181
@metascroy metascroy force-pushed the export-D108048181 branch 2 times, most recently from 803f6d3 to ea24622 Compare June 10, 2026 18:18
@metascroy metascroy requested a review from psiddh June 10, 2026 18:19
@metascroy metascroy merged commit 4ed31d3 into pytorch:main Jun 10, 2026
176 of 181 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants