Skip to content

[ORT] onnxruntime_perf_test: Add multi-shape profiling support to perftest tool (--data_shape) - #29571

Merged
Edward Chen (edgchen1) merged 3 commits into
microsoft:mainfrom
intel:niharika/multi_shape_perf_test
Jul 9, 2026
Merged

[ORT] onnxruntime_perf_test: Add multi-shape profiling support to perftest tool (--data_shape) #29571
Edward Chen (edgchen1) merged 3 commits into
microsoft:mainfrom
intel:niharika/multi_shape_perf_test

Conversation

@ankitm3k

@ankitm3k Ankit Maheshkar (ankitm3k) commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a --data_shape flag to onnxruntime_perf_test app that enables profiling multiple input shapes within a single session. The model is compiled once and then run with each specified shape group in round-robin order, providing per-shape latency statistics (Avg, Min, Max, P50, P90, P95, P99). This is useful for evaluating dynamic-shape model performance across different input dimensions without needing to recompile or restart the session for each shape.

Usage:

#With -I (generate random default inputs of specified shapes):
onnxruntime_perf_test.exe -v -e cpu -m times -r 10 -I --data_shape "data:[1,3,60,10][1,3,60,20]" "model.onnx"

#Without -I (select matching test data folders):
onnxruntime_perf_test.exe -v -e cpu -m times -r 10 --data_shape "data:[1,3,60,10][1,3,60,20]" "model.onnx"

Motivation and Context

Addresses the feature request: #28628

…ta_shape) (#1132)

Usage:

.\onnxruntime_perf_test.exe -v -e openvino -m times -r 10 -I --data_shape "data:[1,3,60,40][1,3,60,60]" -i "device_type|NPU" "PSO2_ctx.onnx"

or, using testdata-

.\onnxruntime_perf_test.exe -v -e openvino -m times -r 10 --data_shape "data:[1,3,60,40][1,3,60,60]" -i "device_type|NPU" "PSO2_ctx.onnx"

Addresses the feature request: microsoft#28628

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the onnxruntime_perf_test tool to support multi-shape profiling via a new --data_shape flag, enabling a single session to run multiple input shape groups (round-robin) and report per-shape latency statistics.

Changes:

  • Added --data_shape CLI flag parsing and storage in RunConfig.
  • Implemented multi-shape input generation/selection and round-robin execution, with per-shape latency tracking and reporting.
  • Added a small ONNX model generator script for exercising multi-shape behavior.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
onnxruntime/test/testdata/dynamic_shape_add.py Adds a small dynamic-shape ONNX model generator for testing --data_shape.
onnxruntime/test/perftest/test_session.h Extends RunTiming to carry the shape group index used by an iteration.
onnxruntime/test/perftest/test_configuration.h Adds RunConfig::data_shape_groups to hold per-input shape groups.
onnxruntime/test/perftest/strings_helper.h Declares ParseDataShapeGroups for parsing the --data_shape argument.
onnxruntime/test/perftest/strings_helper.cc Implements ParseDataShapeGroups string parsing + validation.
onnxruntime/test/perftest/performance_runner.h Adds per-shape timing storage to PerformanceResult and a printing helper.
onnxruntime/test/perftest/performance_runner.cc Implements warmup per shape group, per-shape stats reporting, and multi-shape init paths.
onnxruntime/test/perftest/ort_test_session.h Adds round-robin controls and helper APIs for multi-shape test data selection.
onnxruntime/test/perftest/ort_test_session.cc Implements round-robin selection and multi-shape input generation; tags timing with shape index.
onnxruntime/test/perftest/command_args_parser.cc Adds the --data_shape flag and wires parsing into RunConfig.

Comment thread onnxruntime/test/perftest/ort_test_session.cc
Comment thread onnxruntime/test/perftest/ort_test_session.cc
Comment thread onnxruntime/test/testdata/dynamic_shape_add.py Outdated
Comment thread onnxruntime/test/perftest/performance_runner.cc Outdated
Comment thread onnxruntime/test/perftest/ort_test_session.h Outdated
Comment thread onnxruntime/test/perftest/ort_test_session.cc Outdated
Comment thread onnxruntime/test/perftest/strings_helper.cc Outdated
Comment thread onnxruntime/test/testdata/dynamic_shape_add.py Outdated
Comment thread onnxruntime/test/perftest/performance_runner.cc Outdated
Comment thread onnxruntime/test/perftest/ort_test_session.cc
Comment thread onnxruntime/test/perftest/performance_runner.cc Outdated
@n1harika

n1harika commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Thanks Edward Chen (@edgchen1) for the review! Comments are addressed.

Comment thread onnxruntime/test/perftest/performance_runner.cc Outdated
Comment thread onnxruntime/test/perftest/ort_test_session.cc
Comment thread onnxruntime/test/perftest/strings_helper.cc

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Comment thread onnxruntime/test/perftest/strings_helper.h
Comment thread onnxruntime/test/perftest/strings_helper.cc
Comment thread onnxruntime/test/perftest/strings_helper.cc
Comment thread onnxruntime/test/perftest/ort_test_session.cc
Comment thread onnxruntime/test/perftest/ort_test_session.cc
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.

5 participants