From 0cd43961809dbebe4108bb4ab0f06ad786400b4c Mon Sep 17 00:00:00 2001 From: TolyaTalamanov Date: Mon, 3 Oct 2022 11:08:15 +0000 Subject: [PATCH] Expand modeling tool to support infer_mode --- modules/gapi/samples/pipeline_modeling_tool.cpp | 16 +++++++++++++++- .../pipeline_modeling_tool/pipeline_builder.hpp | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/gapi/samples/pipeline_modeling_tool.cpp b/modules/gapi/samples/pipeline_modeling_tool.cpp index 60547a9c9b..f7a44388c2 100644 --- a/modules/gapi/samples/pipeline_modeling_tool.cpp +++ b/modules/gapi/samples/pipeline_modeling_tool.cpp @@ -175,6 +175,17 @@ static PLMode strToPLMode(const std::string& mode_str) { } } +static cv::gapi::ie::InferMode strToInferMode(const std::string& infer_mode) { + if (infer_mode == "async") { + return cv::gapi::ie::InferMode::Async; + } else if (infer_mode == "sync") { + return cv::gapi::ie::InferMode::Sync; + } else { + throw std::logic_error("Unsupported Infer mode: " + infer_mode + + "\nPlease chose between: async and sync"); + } +} + template <> CallParams read(const cv::FileNode& fn) { auto name = @@ -282,7 +293,8 @@ int main(int argc, char* argv[]) { "{ drop_frames | false | Drop frames if they come earlier than pipeline is completed. }" "{ exec_list | | A comma-separated list of pipelines that" " will be executed. Spaces around commas" - " are prohibited. }"; + " are prohibited. }" + "{ infer_mode | async | OpenVINO inference mode (async/sync). }"; cv::CommandLineParser cmd(argc, argv, keys); if (cmd.has("help")) { @@ -298,6 +310,7 @@ int main(int argc, char* argv[]) { const auto qc = cmd.get("qc"); const auto app_mode = strToAppMode(cmd.get("app_mode")); const auto exec_str = cmd.get("exec_list"); + const auto infer_mode = strToInferMode(cmd.get("infer_mode")); const auto drop_frames = cmd.get("drop_frames"); cv::FileStorage fs; @@ -388,6 +401,7 @@ int main(int argc, char* argv[]) { << call_params.name << std::endl << e.what(); throw std::logic_error(ss.str()); } + infer_params.mode = infer_mode; builder.addInfer(call_params, infer_params); } else { throw std::logic_error("Unsupported node type: " + node_type); diff --git a/modules/gapi/samples/pipeline_modeling_tool/pipeline_builder.hpp b/modules/gapi/samples/pipeline_modeling_tool/pipeline_builder.hpp index a3f187249d..e981dae22d 100644 --- a/modules/gapi/samples/pipeline_modeling_tool/pipeline_builder.hpp +++ b/modules/gapi/samples/pipeline_modeling_tool/pipeline_builder.hpp @@ -258,6 +258,7 @@ struct InferParams { std::vector input_layers; std::vector output_layers; std::map config; + cv::gapi::ie::InferMode mode; }; class PipelineBuilder { @@ -362,6 +363,7 @@ void PipelineBuilder::addInfer(const CallParams& call_params, } pp->pluginConfig(infer_params.config); + pp->cfgInferMode(infer_params.mode); m_state->networks += cv::gapi::networks(*pp); addCall(call_params,