Skip to content

Conversation

jatinwadhwa921
Copy link

This PR introduces a new provider option that allows users to explicitly set the layout for model inputs and outputs

The layout can be configured using the following command-line format:

onnxruntime_perf_test.exe -v -e openvino -m times -r 1 -I -i  "device_type|NPU layout|data_0[NCHW],prob_1[NC]" "C:\Users\Administrator\Downloads\bvlcalexnet-12.onnx"
  • Users can specify standard layout characters like "N", "C", "H", "W", or use "?" as a placeholder if the layout dimension is unknown.
  • If an invalid input or output name is provided, a warning will be logged, and the layout setting will be ignored for that specific input or output.

@@ -828,6 +828,8 @@ select from 'TF8', 'TF16', 'UINT8', 'FLOAT', 'ITENSOR'. \n)");
ov_options[key] = value;
} else if (key == "reshape_input") {
ov_options[key] = value;
} else if (key == "layout") {
ov_options[key] = value;

Choose a reason for hiding this comment

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

Should we then also update the THROW message?

ORT_THROW(
            "[ERROR] [OpenVINO] wrong key type entered. Choose from the following runtime key options that are available for OpenVINO."
            " ['device_type', 'device_id', 'num_of_threads', 'load_config', 'cache_dir', 'num_streams', "
            "'enable_opencl_throttling', 'disable_dynamic_shapes', 'enable_qdq_optimizer',"
            " 'enable_causallm', 'model_priority', 'layout'] \n");

Copy link
Author

Choose a reason for hiding this comment

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

fixed

std::unordered_set<char> seen_alphabets;
for (char c : layout_str) {
if (std::isalpha(c)) {
char upper_c = std::toupper(c); // Convert to uppercase for case-insensitive comparison
Copy link

@DariaMityagina DariaMityagina Aug 2, 2025

Choose a reason for hiding this comment

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

Hope this helps. The following error occurred during Windows build:

error C2220: the following warning is treated as an error [...\onnxruntime\build\Windows\Release\onnxruntime_providers_openvino.vcxproj] ...\onnxruntime\onnxruntime\core\providers\openvino\openvino_parser_utils.cc(297,20): warning C4244: 'initializing': conversion from 'int' to 'char', possible loss of data

This change helped me fix the issue:

char upper_c = static_cast<char>(std::toupper(c));

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@DariaMityagina
Copy link

@sfatimar, @preetha-intel hi!
Could you please review this PR?

Copy link

@preetha-intel preetha-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@preetha-intel preetha-intel merged commit a6359ee into ovep-develop Aug 14, 2025
6 of 8 checks passed
@jatinwadhwa921 jatinwadhwa921 added the ovep_abi_1.0 PRs that need to go in ABI need to have this label. label Aug 26, 2025
vthaniel pushed a commit that referenced this pull request Aug 28, 2025
* [OVEP] Support for providing layout to input/output to OpenVINO

* [OVEP] Minor bug fixes for layout feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ovep_abi_1.0 PRs that need to go in ABI need to have this label.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants