Skip to content

[OVEP] Support for providing layout to input/output to OpenVINO #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: ovep-develop
Choose a base branch
from

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?

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.

2 participants