[CVS-187745] Add multi-shape profiling support to perftest tool (--data_shape)#1132
Open
n1harika wants to merge 9 commits into
Open
[CVS-187745] Add multi-shape profiling support to perftest tool (--data_shape)#1132n1harika wants to merge 9 commits into
n1harika wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
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_shapecommand-line flag and parsing intoRunConfig::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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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"