From 1c51f54273019d2d530d579d820a95bba271d8d6 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Fri, 25 Oct 2024 15:35:05 +0300 Subject: [PATCH 01/22] building --- src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp | 5 ++++- .../intel_npu/tools/protopipe/src/scenario/inference.hpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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 34099d36a69fdb..0a664ab3f86b29 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["shape"]) { + params.shape = node["shape"].as>> (); + } + if (node["config"]) { params.config = node["config"].as>(); } @@ -474,7 +478,6 @@ struct convert { if (node["input_data"]) { op.input_data = node["input_data"].as>(); } - if (node["output_data"]) { op.output_data = node["output_data"].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 c4fd85aa26721a..05f024e460d430 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> shape; std::map config; size_t nireq = 1u; }; From b7e9f9a325387077cce851c590d865c41fd85902 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Mon, 28 Oct 2024 13:55:27 +0200 Subject: [PATCH 02/22] Building and working --- .../tools/protopipe/src/parser/config.cpp | 2 +- .../tools/protopipe/src/scenario/inference.hpp | 2 +- .../protopipe/src/simulation/ov_layers_reader.cpp | 14 ++++++++++++++ .../tools/protopipe/src/simulation/simulation.cpp | 5 +++++ 4 files changed, 21 insertions(+), 2 deletions(-) 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 0a664ab3f86b29..1ae9e992876a8c 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp @@ -346,7 +346,7 @@ struct convert { } if (node["shape"]) { - params.shape = node["shape"].as>> (); + params.shape = node["shape"].as>> (); } if (node["config"]) { 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 05f024e460d430..ee9a551c27cc2e 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp +++ b/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp @@ -91,7 +91,7 @@ struct OpenVINOParams { LayerVariantAttr output_layout; LayerVariantAttr input_model_layout; LayerVariantAttr output_model_layout; - LayerVariantAttr> shape; + LayerVariantAttr> shape; 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..49f60cfb2b69da 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 @@ -157,6 +157,20 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p model = ppp.build(); } + std::map partial_shapes; + if (std::holds_alternative>>(params.shape)) { + auto &shapeMap = std::get>>(params.shape); + std::vector dims; + for (auto& shape : shapeMap) { + for (auto& dim : shape.second) { + dims.push_back(dim); + } + partial_shapes[shape.first] = dims; + } + } else { //SeNe ToDo + + } + model->reshape(partial_shapes); auto input_layers = ovToLayersInfo(model->inputs()); auto output_layers = ovToLayersInfo(model->outputs()); 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 52f57c2881a3b6..d1c8b0a01505f6 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -22,7 +22,12 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN const auto& blob_path = std::get(params.path); network = std::make_unique

(tag, blob_path.blob, params.device); } + if (std::holds_alternative>>(params.shape)) { + auto &shapeMap = std::get>>(params.shape); + network->cfgReshape(shapeMap); + } else { //SeNe ToDo + } network->cfgPluginConfig(params.config); network->cfgNumRequests(params.nireq); From 22bafff532889d46aa9ad0d8913af2abd5395e31 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Mon, 28 Oct 2024 14:44:26 +0200 Subject: [PATCH 03/22] Building --- .../src/simulation/ov_layers_reader.cpp | 16 +++++++++------- .../protopipe/src/simulation/simulation.cpp | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) 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 49f60cfb2b69da..5cb60d14cb20bc 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 @@ -162,15 +162,17 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p auto &shapeMap = std::get>>(params.shape); std::vector dims; for (auto& shape : shapeMap) { - for (auto& dim : shape.second) { - dims.push_back(dim); - } - partial_shapes[shape.first] = dims; + for (auto& dim : shape.second) { dims.emplace_back(dim); } + partial_shapes[shape.first] = dims; } - } else { //SeNe ToDo - + model->reshape(partial_shapes); + } else if (std::holds_alternative>(params.shape)) { + std::vector vecDims = std::get>(params.shape); + ov::PartialShape dims; + for (auto& dim : vecDims) { dims.emplace_back(dim); } + model->reshape(dims); } - model->reshape(partial_shapes); + auto input_layers = ovToLayersInfo(model->inputs()); auto output_layers = ovToLayersInfo(model->outputs()); 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 d1c8b0a01505f6..10f4093f4980fd 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -25,9 +25,11 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN if (std::holds_alternative>>(params.shape)) { auto &shapeMap = std::get>>(params.shape); network->cfgReshape(shapeMap); - } else { //SeNe ToDo - + } else if (std::holds_alternative>(params.shape)) { + auto &shape = std::get>(params.shape); + network->cfgReshape(shape); } + network->cfgPluginConfig(params.config); network->cfgNumRequests(params.nireq); From fae44b51175a585c2d269fcd8f7de045c280ac73 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Mon, 28 Oct 2024 15:52:03 +0200 Subject: [PATCH 04/22] Refactoring --- .../protopipe/src/simulation/ov_layers_reader.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 5cb60d14cb20bc..73ac45184e05a4 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,18 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: } } +static void cfgModelPartialShapes(const std::shared_ptr& model, + const AttrMap> shape_map) { + + std::map partial_shapes; + for (const auto& shape : shape_map) { + std::vector vecDimension; + for (const auto& dimension : shape.second) { vecDimension.emplace_back(dimension); } + partial_shapes[shape.first] = std::move(vecDimension); + } + 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 +160,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 shape_map = unpackLayerAttr(params.shape, input_names, "dynamic shape"); + cfgModelPartialShapes(model, shape_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"); From 8fbadeeee0e6c65547e4511fc456e41d28eb50a9 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 29 Oct 2024 09:11:53 +0200 Subject: [PATCH 05/22] Refactoring --- .../intel_npu/tools/protopipe/src/simulation/simulation.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 10f4093f4980fd..0dfca14c8b6767 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -23,11 +23,9 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN network = std::make_unique

(tag, blob_path.blob, params.device); } if (std::holds_alternative>>(params.shape)) { - auto &shapeMap = std::get>>(params.shape); - network->cfgReshape(shapeMap); + network->cfgReshape(std::get>>(params.shape)); } else if (std::holds_alternative>(params.shape)) { - auto &shape = std::get>(params.shape); - network->cfgReshape(shape); + network->cfgReshape(std::get>(params.shape)); } network->cfgPluginConfig(params.config); From 375f7f1b259e076b56fe7679b8e696821b65bee0 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 29 Oct 2024 09:24:35 +0200 Subject: [PATCH 06/22] Refactoring --- .../intel_npu/tools/protopipe/src/parser/config.cpp | 1 + .../tools/protopipe/src/simulation/ov_layers_reader.cpp | 8 ++++---- .../tools/protopipe/src/simulation/simulation.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) 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 1ae9e992876a8c..465686b102c310 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp @@ -478,6 +478,7 @@ struct convert { if (node["input_data"]) { op.input_data = node["input_data"].as>(); } + if (node["output_data"]) { op.output_data = node["output_data"].as>(); } 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 73ac45184e05a4..cacc3c250a2899 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,8 +128,8 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: } } -static void cfgModelPartialShapes(const std::shared_ptr& model, - const AttrMap> shape_map) { +static void cfgPartialShapes(const std::shared_ptr& model, + const AttrMap> shape_map) { std::map partial_shapes; for (const auto& shape : shape_map) { @@ -161,7 +161,7 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p cfgInputPreproc(ppp, model, ip_map, il_map, iml_map); const auto shape_map = unpackLayerAttr(params.shape, input_names, "dynamic shape"); - cfgModelPartialShapes(model, shape_map); + cfgPartialShapes(model, shape_map); const auto& output_names = extractLayerNames(model->outputs()); const auto op_map = unpackLayerAttr(params.output_precision, output_names, "output precision"); @@ -181,7 +181,7 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p partial_shapes[shape.first] = dims; } model->reshape(partial_shapes); - } else if (std::holds_alternative>(params.shape)) { + } else { std::vector vecDims = std::get>(params.shape); ov::PartialShape dims; for (auto& dim : vecDims) { dims.emplace_back(dim); } 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 0dfca14c8b6767..383dc80b97b2c0 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -24,7 +24,7 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN } if (std::holds_alternative>>(params.shape)) { network->cfgReshape(std::get>>(params.shape)); - } else if (std::holds_alternative>(params.shape)) { + } else { network->cfgReshape(std::get>(params.shape)); } From adf197a8bd07d20261e6b20a00c7e23f25d0a985 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 5 Nov 2024 09:43:11 +0200 Subject: [PATCH 07/22] Refactoring --- .../src/simulation/ov_layers_reader.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) 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 cacc3c250a2899..cc492d3fd25c8f 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 @@ -160,7 +160,7 @@ 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 shape_map = unpackLayerAttr(params.shape, input_names, "dynamic shape"); + const auto shape_map = unpackLayerAttr(params.shape, input_names, "shape"); cfgPartialShapes(model, shape_map); const auto& output_names = extractLayerNames(model->outputs()); @@ -172,22 +172,6 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p model = ppp.build(); } - std::map partial_shapes; - if (std::holds_alternative>>(params.shape)) { - auto &shapeMap = std::get>>(params.shape); - std::vector dims; - for (auto& shape : shapeMap) { - for (auto& dim : shape.second) { dims.emplace_back(dim); } - partial_shapes[shape.first] = dims; - } - model->reshape(partial_shapes); - } else { - std::vector vecDims = std::get>(params.shape); - ov::PartialShape dims; - for (auto& dim : vecDims) { dims.emplace_back(dim); } - model->reshape(dims); - } - auto input_layers = ovToLayersInfo(model->inputs()); auto output_layers = ovToLayersInfo(model->outputs()); From b08f5d949038c880fa554b43d0fc4002558edfef Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 5 Nov 2024 10:04:57 +0200 Subject: [PATCH 08/22] Documentation --- src/plugins/intel_npu/tools/protopipe/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/intel_npu/tools/protopipe/README.md b/src/plugins/intel_npu/tools/protopipe/README.md index afe6e8cffbc8c3..718b77a8af63d6 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. +- `shape` - **Optional**. Input layer shape. Examples: ``` From 76c8b383e21d3b7c0bbf3f8d2a6037b0f3c4c8b8 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 5 Nov 2024 15:26:19 +0200 Subject: [PATCH 09/22] option "shape" renamed to "reshape" --- src/plugins/intel_npu/tools/protopipe/README.md | 2 +- src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp | 4 ++-- .../intel_npu/tools/protopipe/src/scenario/inference.hpp | 2 +- .../tools/protopipe/src/simulation/ov_layers_reader.cpp | 2 +- .../intel_npu/tools/protopipe/src/simulation/simulation.cpp | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/intel_npu/tools/protopipe/README.md b/src/plugins/intel_npu/tools/protopipe/README.md index 718b77a8af63d6..f512592f54192a 100644 --- a/src/plugins/intel_npu/tools/protopipe/README.md +++ b/src/plugins/intel_npu/tools/protopipe/README.md @@ -60,7 +60,7 @@ log_level: INFO - `ol` - **Optional**. Output layer layout. - `iml` - **Optional**. Input model layout. - `oml` - **Optional**. Output model layout. -- `shape` - **Optional**. Input layer shape. +- `reshape` - **Optional**. Set shape for input layer. For example, "input1: [1,3,224,224], input2: [1,4]" or "[1,3,224,224]" in case of one input size. 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 465686b102c310..b5337d127c442d 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp @@ -345,8 +345,8 @@ struct convert { params.output_model_layout = node["oml"].as>(); } - if (node["shape"]) { - params.shape = node["shape"].as>> (); + if (node["reshape"]) { + params.reshape = node["reshape"].as>> (); } if (node["config"]) { 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 ee9a551c27cc2e..c87e9d49459785 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp +++ b/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp @@ -91,7 +91,7 @@ struct OpenVINOParams { LayerVariantAttr output_layout; LayerVariantAttr input_model_layout; LayerVariantAttr output_model_layout; - LayerVariantAttr> shape; + 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 cc492d3fd25c8f..7c1cb9a33170fb 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 @@ -160,7 +160,7 @@ 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 shape_map = unpackLayerAttr(params.shape, input_names, "shape"); + const auto shape_map = unpackLayerAttr(params.reshape, input_names, "shape"); cfgPartialShapes(model, shape_map); const auto& output_names = extractLayerNames(model->outputs()); 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 383dc80b97b2c0..76e5b6c2837e4c 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -22,10 +22,10 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN const auto& blob_path = std::get(params.path); network = std::make_unique

(tag, blob_path.blob, params.device); } - if (std::holds_alternative>>(params.shape)) { - network->cfgReshape(std::get>>(params.shape)); + if (std::holds_alternative>>(params.reshape)) { + network->cfgReshape(std::get>>(params.reshape)); } else { - network->cfgReshape(std::get>(params.shape)); + network->cfgReshape(std::get>(params.reshape)); } network->cfgPluginConfig(params.config); From 838eb3984e4ba2ded6db23f8d23a252f121ce182 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 5 Nov 2024 15:55:55 +0200 Subject: [PATCH 10/22] Refactoring after code review --- .../protopipe/src/simulation/ov_layers_reader.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 7c1cb9a33170fb..e2fed86f506f27 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 @@ -131,11 +131,15 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: static void cfgPartialShapes(const std::shared_ptr& model, const AttrMap> shape_map) { + // std::map partial_shapes; + // for (const auto& shape : shape_map) { + // std::vector vecDimension; + // for (const auto& dimension : shape.second) { vecDimension.emplace_back(dimension); } + // partial_shapes[shape.first] = std::move(vecDimension); + // } std::map partial_shapes; - for (const auto& shape : shape_map) { - std::vector vecDimension; - for (const auto& dimension : shape.second) { vecDimension.emplace_back(dimension); } - partial_shapes[shape.first] = std::move(vecDimension); + for (const auto& [layer_name, shape] : shape_map) { + partial_shapes.emplace(layer_name, shape); } model->reshape(partial_shapes); } From 97f7c1a091740ad1f77c15f28cb50718724978ba Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 5 Nov 2024 15:57:35 +0200 Subject: [PATCH 11/22] Refactoring after code review --- .../protopipe/src/simulation/ov_layers_reader.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) 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 e2fed86f506f27..8bce04247595f6 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,15 +128,8 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: } } -static void cfgPartialShapes(const std::shared_ptr& model, - const AttrMap> shape_map) { - - // std::map partial_shapes; - // for (const auto& shape : shape_map) { - // std::vector vecDimension; - // for (const auto& dimension : shape.second) { vecDimension.emplace_back(dimension); } - // partial_shapes[shape.first] = std::move(vecDimension); - // } +static void cfgReshape(const std::shared_ptr& model, + const AttrMap> shape_map) { std::map partial_shapes; for (const auto& [layer_name, shape] : shape_map) { partial_shapes.emplace(layer_name, shape); @@ -165,7 +158,7 @@ InOutLayers OpenVINOLayersReader::Impl::readFromModel(const std::string& model_p cfgInputPreproc(ppp, model, ip_map, il_map, iml_map); const auto shape_map = unpackLayerAttr(params.reshape, input_names, "shape"); - cfgPartialShapes(model, shape_map); + cfgReshape(model, shape_map); const auto& output_names = extractLayerNames(model->outputs()); const auto op_map = unpackLayerAttr(params.output_precision, output_names, "output precision"); From b775841bfb7552c88b63a949dbb72f96c67e83c7 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 5 Nov 2024 17:10:02 +0200 Subject: [PATCH 12/22] Refactoring after code review --- src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp | 2 +- .../intel_npu/tools/protopipe/src/scenario/inference.hpp | 2 +- .../tools/protopipe/src/simulation/ov_layers_reader.cpp | 2 +- .../intel_npu/tools/protopipe/src/simulation/simulation.cpp | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) 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 b5337d127c442d..7417b3884dba58 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp @@ -346,7 +346,7 @@ struct convert { } if (node["reshape"]) { - params.reshape = node["reshape"].as>> (); + params.reshape = node["reshape"].as>> (); } if (node["config"]) { 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 c87e9d49459785..c10b9768252a40 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp +++ b/src/plugins/intel_npu/tools/protopipe/src/scenario/inference.hpp @@ -91,7 +91,7 @@ struct OpenVINOParams { LayerVariantAttr output_layout; LayerVariantAttr input_model_layout; LayerVariantAttr output_model_layout; - LayerVariantAttr> reshape; + 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 8bce04247595f6..f15bcba8b9ebc5 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 @@ -129,7 +129,7 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: } static void cfgReshape(const std::shared_ptr& model, - const AttrMap> shape_map) { + const AttrMap> shape_map) { std::map partial_shapes; for (const auto& [layer_name, shape] : shape_map) { partial_shapes.emplace(layer_name, shape); 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 76e5b6c2837e4c..b7ea9278f1f24b 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/simulation.cpp @@ -22,10 +22,10 @@ static cv::gapi::GNetPackage getNetPackage(const std::string& tag, const OpenVIN const auto& blob_path = std::get(params.path); network = std::make_unique

(tag, blob_path.blob, params.device); } - if (std::holds_alternative>>(params.reshape)) { - network->cfgReshape(std::get>>(params.reshape)); + if (std::holds_alternative>>(params.reshape)) { + network->cfgReshape(std::get>>(params.reshape)); } else { - network->cfgReshape(std::get>(params.reshape)); + network->cfgReshape(std::get>(params.reshape)); } network->cfgPluginConfig(params.config); From 13958f69a498426c69001e862b2f5fa79e5a6f6e Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Mon, 11 Nov 2024 14:39:48 +0200 Subject: [PATCH 13/22] Code changes after review --- src/plugins/intel_npu/tools/protopipe/README.md | 2 +- .../tools/protopipe/src/simulation/ov_layers_reader.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/intel_npu/tools/protopipe/README.md b/src/plugins/intel_npu/tools/protopipe/README.md index f512592f54192a..5fbf6150731d65 100644 --- a/src/plugins/intel_npu/tools/protopipe/README.md +++ b/src/plugins/intel_npu/tools/protopipe/README.md @@ -60,7 +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 layer. For example, "input1: [1,3,224,224], input2: [1,4]" or "[1,3,224,224]" in case of one input size. +- `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/simulation/ov_layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/ov_layers_reader.cpp index f15bcba8b9ebc5..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 @@ -129,9 +129,9 @@ static void cfgOutputPostproc(ov::preprocess::PrePostProcessor& ppp, const std:: } static void cfgReshape(const std::shared_ptr& model, - const AttrMap> shape_map) { + const AttrMap> reshape_map) { std::map partial_shapes; - for (const auto& [layer_name, shape] : shape_map) { + for (const auto& [layer_name, shape] : reshape_map) { partial_shapes.emplace(layer_name, shape); } model->reshape(partial_shapes); @@ -157,8 +157,8 @@ 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 shape_map = unpackLayerAttr(params.reshape, input_names, "shape"); - cfgReshape(model, shape_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"); From fdbdd7f19677431668531c6b13870b62e1b199b1 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Mon, 11 Nov 2024 16:22:55 +0200 Subject: [PATCH 14/22] Test --- .../tools/protopipe/src/simulation/ov_layers_reader.cpp | 1 + 1 file changed, 1 insertion(+) 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 33e01e36404570..c664ce4d65228e 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 @@ -72,6 +72,7 @@ static int toPrecision(ov::element::Type prec) { template std::vector ovToLayersInfo(const InfoVec& vec) { + std::cout << "Septi Here" << std::endl; std::vector layers; layers.reserve(vec.size()); std::transform(vec.begin(), vec.end(), std::back_inserter(layers), [](const auto& node) { From 63c30fe18a2b2b1a23c46003fe82493b34dd592f Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Tue, 12 Nov 2024 13:49:53 +0200 Subject: [PATCH 15/22] Test --- .../intel_npu/tools/protopipe/main.cpp | 1 + .../src/simulation/layers_reader.cpp | 1 + .../src/simulation/ov_layers_reader.cpp | 26 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/plugins/intel_npu/tools/protopipe/main.cpp b/src/plugins/intel_npu/tools/protopipe/main.cpp index 8596ba864335ca..9655f8921609a0 100644 --- a/src/plugins/intel_npu/tools/protopipe/main.cpp +++ b/src/plugins/intel_npu/tools/protopipe/main.cpp @@ -178,6 +178,7 @@ static Simulation::Ptr createSimulation(const std::string& mode, StreamDesc&& st } int main(int argc, char* argv[]) { + std::cout << "Septi main" << std::endl; // NB: Intentionally wrapped into try-catch to display exceptions occur on windows. try { if (!parseCommandLine(&argc, &argv)) { diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index 72c1e9539773e3..d1d6ab7637f86d 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -38,6 +38,7 @@ InOutLayers LayersReader::readLayers(const InferenceParams& params) { return getOVReader().readLayers(ov); } ASSERT(std::holds_alternative(params)); + std::cout << "Septi LayersReader::readLayers" << std::endl; const auto& ort = std::get(params); // NB: Using OpenVINO to read the i/o layers information for *.onnx model OpenVINOParams ov; 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 c664ce4d65228e..059896c9e1a377 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 @@ -72,12 +72,36 @@ static int toPrecision(ov::element::Type prec) { template std::vector ovToLayersInfo(const InfoVec& vec) { - std::cout << "Septi Here" << std::endl; + std::cout << "Septi ovToLayersInfo start" << std::endl; std::vector layers; layers.reserve(vec.size()); + std::cout << "Septi ovToLayersInfo get_partial_shape" << std::endl; + for (auto& node : vec) { + std::cout << "New node ---- : " << std::endl; + auto partialShape = node.get_partial_shape(); + std::vector newDimension; + for (auto& shape : partialShape) { + std::cout << "New shape ---- : " << std::endl; + std::cout << "shape is dynamic: " << shape.is_dynamic() << std::endl; + std::cout << "shape is static: " << shape.is_static() << std::endl; + std::cout << shape.to_string() < Date: Wed, 13 Nov 2024 09:08:46 +0200 Subject: [PATCH 16/22] Working --- .../src/simulation/layers_reader.cpp | 19 +++++++-- .../src/simulation/ov_layers_reader.cpp | 42 +++++-------------- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index d1d6ab7637f86d..9bcb4a02e745c3 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -31,17 +31,30 @@ static std::string getModelFileName(const InferenceParams& params) { ASSERT(false); } +static void adjustLayerPartialShapes(LayersInfo& layers) { + for (auto& layer : layers) { + for (auto& dim : layer.dims) { + if (dim == -1) { + LOG_INFO() << "Dynamic partial shape detected for layer " << layer.name << " partial shape will be set to 1" << std::endl; + dim = 1; + } + } + } +} + InOutLayers LayersReader::readLayers(const InferenceParams& params) { - LOG_INFO() << "Reading model " << getModelFileName(params) << std::endl; if (std::holds_alternative(params)) { const auto& ov = std::get(params); return getOVReader().readLayers(ov); } ASSERT(std::holds_alternative(params)); - std::cout << "Septi LayersReader::readLayers" << std::endl; const auto& ort = std::get(params); // NB: Using OpenVINO to read the i/o layers information for *.onnx model OpenVINOParams ov; ov.path = OpenVINOParams::ModelPath{ort.model_path, ""}; - return getOVReader().readLayers(ov, true /* use_results_names */); + auto inOutLayers = getOVReader().readLayers(ov, true /* use_results_names */); + adjustLayerPartialShapes(inOutLayers.in_layers); + adjustLayerPartialShapes(inOutLayers.out_layers); + + return inOutLayers; } 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 059896c9e1a377..02b25343315691 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 @@ -44,12 +44,17 @@ static ov::element::Type toElementType(int cvdepth) { throw std::logic_error("Failed to convert opencv depth to ov::element::Type"); } -static std::vector toDims(const std::vector& sz_vec) { +static std::vector toDims(const ov::PartialShape& partialShape) { std::vector result; - result.reserve(sz_vec.size()); - for (auto sz : sz_vec) { - // FIXME: Probably requires some check... - result.push_back(static_cast(sz)); + + result.reserve(partialShape.size()); + for (const auto dim : partialShape) + { + if (dim.is_dynamic()) { + result.push_back(-1); + } else { + result.push_back(static_cast(dim.get_length())); + } } return result; } @@ -72,36 +77,11 @@ static int toPrecision(ov::element::Type prec) { template std::vector ovToLayersInfo(const InfoVec& vec) { - std::cout << "Septi ovToLayersInfo start" << std::endl; std::vector layers; layers.reserve(vec.size()); - std::cout << "Septi ovToLayersInfo get_partial_shape" << std::endl; - for (auto& node : vec) { - std::cout << "New node ---- : " << std::endl; - auto partialShape = node.get_partial_shape(); - std::vector newDimension; - for (auto& shape : partialShape) { - std::cout << "New shape ---- : " << std::endl; - std::cout << "shape is dynamic: " << shape.is_dynamic() << std::endl; - std::cout << "shape is static: " << shape.is_static() << std::endl; - std::cout << shape.to_string() < Date: Wed, 13 Nov 2024 09:17:41 +0200 Subject: [PATCH 17/22] Fix --- src/plugins/intel_npu/tools/protopipe/main.cpp | 1 - .../intel_npu/tools/protopipe/src/simulation/layers_reader.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_npu/tools/protopipe/main.cpp b/src/plugins/intel_npu/tools/protopipe/main.cpp index 9655f8921609a0..8596ba864335ca 100644 --- a/src/plugins/intel_npu/tools/protopipe/main.cpp +++ b/src/plugins/intel_npu/tools/protopipe/main.cpp @@ -178,7 +178,6 @@ static Simulation::Ptr createSimulation(const std::string& mode, StreamDesc&& st } int main(int argc, char* argv[]) { - std::cout << "Septi main" << std::endl; // NB: Intentionally wrapped into try-catch to display exceptions occur on windows. try { if (!parseCommandLine(&argc, &argv)) { diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index 9bcb4a02e745c3..f9ba2eda9d1a75 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -43,6 +43,7 @@ static void adjustLayerPartialShapes(LayersInfo& layers) { } InOutLayers LayersReader::readLayers(const InferenceParams& params) { + LOG_INFO() << "Reading model " << getModelFileName(params) << std::endl; if (std::holds_alternative(params)) { const auto& ov = std::get(params); return getOVReader().readLayers(ov); From c116f8f6b05f868734b424f583973e3e73c20de8 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Thu, 14 Nov 2024 09:40:26 +0200 Subject: [PATCH 18/22] Changes after code review --- .../src/simulation/layers_reader.cpp | 29 +++++++++++++------ .../src/simulation/ov_layers_reader.cpp | 14 +++------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index f9ba2eda9d1a75..5ded37e5c9b65c 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -31,14 +31,25 @@ static std::string getModelFileName(const InferenceParams& params) { ASSERT(false); } -static void adjustLayerPartialShapes(LayersInfo& layers) { +static void adjustDynamicDims(LayersInfo& layers) { + auto dims_to_string = [](const std::vector& dims) { + std::stringstream ss; + std::copy(dims.begin(), dims.end(), std::ostream_iterator(ss, " ")); + return ss.str(); + }; for (auto& layer : layers) { - for (auto& dim : layer.dims) { - if (dim == -1) { - LOG_INFO() << "Dynamic partial shape detected for layer " << layer.name << " partial shape will be set to 1" << std::endl; - dim = 1; - } - } + auto& dims = layer.dims; + if (std::find(dims.begin(), dims.end(), -1) == dims.end()) continue; + std::stringstream info_msg; + info_msg + << "Dynamic shape: [" << dims_to_string(dims) << "] has been detected for layer " + << layer.name + << ". Data with shape ["; + std::for_each(dims.begin(), dims.end(), [](int &v) { v = v == -1 ? -v : v; }); + info_msg + << dims_to_string(dims) + << "] will be provided as input for this layer."; + LOG_INFO() << info_msg.str() << std::endl; } } @@ -54,8 +65,8 @@ InOutLayers LayersReader::readLayers(const InferenceParams& params) { OpenVINOParams ov; ov.path = OpenVINOParams::ModelPath{ort.model_path, ""}; auto inOutLayers = getOVReader().readLayers(ov, true /* use_results_names */); - adjustLayerPartialShapes(inOutLayers.in_layers); - adjustLayerPartialShapes(inOutLayers.out_layers); + adjustDynamicDims(inOutLayers.in_layers); + adjustDynamicDims(inOutLayers.out_layers); return inOutLayers; } 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 02b25343315691..5e3e738e50e1e0 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 @@ -44,18 +44,12 @@ static ov::element::Type toElementType(int cvdepth) { throw std::logic_error("Failed to convert opencv depth to ov::element::Type"); } -static std::vector toDims(const ov::PartialShape& partialShape) { +static std::vector toDims(const ov::PartialShape& partial_shape) { std::vector result; - result.reserve(partialShape.size()); - for (const auto dim : partialShape) - { - if (dim.is_dynamic()) { - result.push_back(-1); - } else { - result.push_back(static_cast(dim.get_length())); - } - } + result.reserve(partial_shape.size()); + auto to_int = [](auto dim) { return dim.is_dynamic() ? -1 : dim.get_length(); }; + std::transform(partial_shape.begin(), partial_shape.end(), std::back_inserter(result), to_int); return result; } From 2f3390702e7f81bfc37814395ab0fb716b0e14bc Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Thu, 14 Nov 2024 09:49:36 +0200 Subject: [PATCH 19/22] Refactoring --- .../protopipe/src/simulation/layers_reader.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index 5ded37e5c9b65c..17f3515693d7a8 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -32,23 +32,19 @@ static std::string getModelFileName(const InferenceParams& params) { } static void adjustDynamicDims(LayersInfo& layers) { - auto dims_to_string = [](const std::vector& dims) { - std::stringstream ss; - std::copy(dims.begin(), dims.end(), std::ostream_iterator(ss, " ")); - return ss.str(); - }; for (auto& layer : layers) { auto& dims = layer.dims; if (std::find(dims.begin(), dims.end(), -1) == dims.end()) continue; std::stringstream info_msg; info_msg - << "Dynamic shape: [" << dims_to_string(dims) << "] has been detected for layer " + << "Dynamic shape: ["; + std::copy(dims.begin(), dims.end(), std::ostream_iterator(info_msg, " ")); + info_msg << "] has been detected for layer " << layer.name << ". Data with shape ["; std::for_each(dims.begin(), dims.end(), [](int &v) { v = v == -1 ? -v : v; }); - info_msg - << dims_to_string(dims) - << "] will be provided as input for this layer."; + std::copy(dims.begin(), dims.end(), std::ostream_iterator(info_msg, " ")); + info_msg << "] will be provided as input for this layer."; LOG_INFO() << info_msg.str() << std::endl; } } From 00e1cfcaf7bd3cf12ae6a741631070e0e953dbe9 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Thu, 14 Nov 2024 12:33:54 +0200 Subject: [PATCH 20/22] Code changes after code review --- .../intel_npu/tools/protopipe/src/simulation/layers_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index 17f3515693d7a8..ba40ade52bb0da 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -35,6 +35,7 @@ static void adjustDynamicDims(LayersInfo& layers) { for (auto& layer : layers) { auto& dims = layer.dims; if (std::find(dims.begin(), dims.end(), -1) == dims.end()) continue; + std::stringstream info_msg; info_msg << "Dynamic shape: ["; @@ -62,7 +63,6 @@ InOutLayers LayersReader::readLayers(const InferenceParams& params) { ov.path = OpenVINOParams::ModelPath{ort.model_path, ""}; auto inOutLayers = getOVReader().readLayers(ov, true /* use_results_names */); adjustDynamicDims(inOutLayers.in_layers); - adjustDynamicDims(inOutLayers.out_layers); return inOutLayers; } From 0dee1d2424436d0da3d28ea4543b4b48f64daf75 Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Thu, 14 Nov 2024 12:37:06 +0200 Subject: [PATCH 21/22] Fixed warning --- .../tools/protopipe/src/simulation/ov_layers_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5e3e738e50e1e0..328167b4d0717a 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 @@ -48,7 +48,7 @@ static std::vector toDims(const ov::PartialShape& partial_shape) { std::vector result; result.reserve(partial_shape.size()); - auto to_int = [](auto dim) { return dim.is_dynamic() ? -1 : dim.get_length(); }; + auto to_int = [](auto dim) { return dim.is_dynamic() ? -1 : static_cast(dim.get_length()); }; std::transform(partial_shape.begin(), partial_shape.end(), std::back_inserter(result), to_int); return result; } From e6ef9f61f224ff3d50b40f71be9440b60c1b986f Mon Sep 17 00:00:00 2001 From: Septimiu Neaga Date: Fri, 15 Nov 2024 12:45:53 +0200 Subject: [PATCH 22/22] Code changes after review --- .../tools/protopipe/src/simulation/layers_reader.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp index ba40ade52bb0da..b4197d73e542f8 100644 --- a/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp +++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/layers_reader.cpp @@ -31,7 +31,7 @@ static std::string getModelFileName(const InferenceParams& params) { ASSERT(false); } -static void adjustDynamicDims(LayersInfo& layers) { +static void adjustDynamicDims(LayersInfo& layers, std::string layer_type) { for (auto& layer : layers) { auto& dims = layer.dims; if (std::find(dims.begin(), dims.end(), -1) == dims.end()) continue; @@ -45,7 +45,7 @@ static void adjustDynamicDims(LayersInfo& layers) { << ". Data with shape ["; std::for_each(dims.begin(), dims.end(), [](int &v) { v = v == -1 ? -v : v; }); std::copy(dims.begin(), dims.end(), std::ostream_iterator(info_msg, " ")); - info_msg << "] will be provided as input for this layer."; + info_msg << "] will be provided as "<< layer_type <<" for this layer."; LOG_INFO() << info_msg.str() << std::endl; } } @@ -62,7 +62,8 @@ InOutLayers LayersReader::readLayers(const InferenceParams& params) { OpenVINOParams ov; ov.path = OpenVINOParams::ModelPath{ort.model_path, ""}; auto inOutLayers = getOVReader().readLayers(ov, true /* use_results_names */); - adjustDynamicDims(inOutLayers.in_layers); + adjustDynamicDims(inOutLayers.in_layers, "input"); + adjustDynamicDims(inOutLayers.out_layers, "output"); return inOutLayers; }