Skip to content

[CVS-187745] Add multi-shape profiling support to perftest tool (--data_shape)#1132

Open
n1harika wants to merge 9 commits into
ovep-developfrom
niharika/multiple_runtime_shapes
Open

[CVS-187745] Add multi-shape profiling support to perftest tool (--data_shape)#1132
n1harika wants to merge 9 commits into
ovep-developfrom
niharika/multiple_runtime_shapes

Conversation

@n1harika

Copy link
Copy Markdown

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"

Copilot AI left a comment

Copy link
Copy Markdown

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 adds multi-shape profiling support to the onnxruntime_perf_test tool via a new --data_shape flag, enabling a single session to run multiple input shape groups (round-robin) and report per-shape latency statistics. It also adds a small dynamic-shape ONNX model generator to help exercise the new flag.

Changes:

  • Add --data_shape command-line flag and parsing into RunConfig::data_shape_groups.
  • Generate/choose per-shape-group inputs (generated inputs with -I, or select matching testdata folders without -I) and run them round-robin while recording per-shape timings.
  • Print per-shape latency stats and add a test model generator script for dynamic shapes.

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 with shape_group_index for per-shape timing attribution.
onnxruntime/test/perftest/test_configuration.h Adds data_shape_groups storage to RunConfig.
onnxruntime/test/perftest/strings_helper.h Declares ParseDataShapeGroups.
onnxruntime/test/perftest/strings_helper.cc Implements --data_shape parsing into grouped shapes per input name.
onnxruntime/test/perftest/performance_runner.h Adds per-shape timing storage in PerformanceResult.
onnxruntime/test/perftest/performance_runner.cc Implements warmup-per-shape, per-shape timing aggregation/printing, and testdata selection by requested shapes.
onnxruntime/test/perftest/ort_test_session.h Adds round-robin controls and helpers for multi-shape mode.
onnxruntime/test/perftest/ort_test_session.cc Implements multi-shape input generation, round-robin selection, and testdata filtering helpers.
onnxruntime/test/perftest/command_args_parser.cc Adds --data_shape flag and hooks parsing into RunConfig.

Comment on lines +208 to +215
// Extract bracket-delimited shape groups: [d0,d1,...][d0,d1,...]
size_t pos = 0;
while (pos < shapes_str.size()) {
if (shapes_str[pos] != '[') {
std::cerr << "Error parsing --data_shape: expected '[' at position " << pos
<< " in shapes for input '" << input_name << "'." << std::endl;
return false;
}
Comment on lines +474 to +478
if (match) {
selected_ids.push_back(test_data_id);
found = true;
break;
}
Comment on lines +1172 to +1180
// Use user-specified shape if available, otherwise fall back to model metadata
auto it = data_shape_groups.find(input_names_str_[i]);
if (it != data_shape_groups.end()) {
input_node_dim = it->second[g];
} else {
input_node_dim = tensor_info.GetShape();
auto transform_fcn = [](int64_t input) { return (input == -1) ? -input : input; };
std::transform(input_node_dim.begin(), input_node_dim.end(), input_node_dim.begin(), transform_fcn);
}
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.

3 participants