From e2fce1a7e758592231f579368158a00fd1ec570b Mon Sep 17 00:00:00 2001 From: Septimiu Neaga <111509085+SeptimiuIoachimNeagaIntel@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:55:19 +0200 Subject: [PATCH] Tests failed without reshape paramter due to uninitilized value (#27814) ### Details: Fixed problem in protopipe - if the "reshape" parameter was not set and not needed application would fail with bad variant access --------- Co-authored-by: Anastasiya(Asya) Pronina --- src/plugins/intel_npu/tools/protopipe/README.md | 1 + .../intel_npu/tools/protopipe/src/parser/config.cpp | 4 ++++ .../tools/protopipe/src/scenario/inference.hpp | 1 + .../protopipe/src/simulation/ov_layers_reader.cpp | 12 ++++++++++++ .../tools/protopipe/src/simulation/simulation.cpp | 6 ++++++ 5 files changed, 24 insertions(+) diff --git a/src/plugins/intel_npu/tools/protopipe/README.md b/src/plugins/intel_npu/tools/protopipe/README.md index 00849ad8bddc9a..807bd744851b70 100644 --- a/src/plugins/intel_npu/tools/protopipe/README.md +++ b/src/plugins/intel_npu/tools/protopipe/README.md @@ -60,6 +60,7 @@ log_level: INFO - `ol` - **Optional**. Output layer layout. - `iml` - **Optional**. Input model layout. - `oml` - **Optional**. Output model layout. +- `reshape` - **Optional**. Set shape for input layers. For example, "input1: [1,3,224,224], input2: [1,4]" or "[1,3,224,224]" in case of one input layer. Examples: ``` diff --git a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp index c2a1bd6415d595..b9f03a97ba3f69 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp @@ -345,6 +345,10 @@ struct convert { params.output_model_layout = node["oml"].as>(); } + if (node["reshape"]) { + params.reshape = node["reshape"].as>> (); + } + if (node["config"]) { params.config = node["config"].as>(); } diff --git a/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp b/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp index e4568c671438bc..f9c8877b05c53e 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp +++ b/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp @@ -91,6 +91,7 @@ struct OpenVINOParams { LayerVariantAttr output_layout; LayerVariantAttr input_model_layout; LayerVariantAttr output_model_layout; + LayerVariantAttr> reshape; std::map config; size_t nireq = 1u; }; diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/ov_layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/ov_layers_reader.cpp index 57527cef0cc4aa..33e01e36404570 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/ov_layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/ov_layers_reader.cpp @@ -128,6 +128,15 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: } } +static void cfgReshape(const std::shared_ptr& model, + const AttrMap> reshape_map) { + std::map partial_shapes; + for (const auto& [layer_name, shape] : reshape_map) { + partial_shapes.emplace(layer_name, shape); + } + model->reshape(partial_shapes); +} + static std::vector extractLayerNames(const std::vector>& nodes) { std::vector names; std::transform(nodes.begin(), nodes.end(), std::back_inserter(names), [](const auto& node) { @@ -148,6 +157,9 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p const auto iml_map = unpackLayerAttr(params.input_model_layout, input_names, "input model layout"); cfgInputPreproc(ppp, model, ip_map, il_map, iml_map); + const auto reshape_map = unpackLayerAttr(params.reshape, input_names, "reshape"); + cfgReshape(model, reshape_map); + const auto& output_names = extractLayerNames(model->outputs()); const auto op_map = unpackLayerAttr(params.output_precision, output_names, "output precision"); const auto ol_map = unpackLayerAttr(params.output_layout, output_names, "output layout"); diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp index 5b1743651b6ef1..5e57ebf8e75e88 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -57,6 +57,12 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN } else if (std::holds_alternative>(params.output_model_layout)) { network->cfgOutputModelLayout(std::get>(params.output_model_layout)); } + + if (std::holds_alternative>>(params.reshape)) { + network->cfgReshape(std::get>>(params.reshape)); + } else if (std::holds_alternative>(params.reshape)) { + network->cfgReshape(std::get>(params.reshape)); + } } return cv::gapi::networks(*network); }