Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Protopipe] Fix: Preserve NPU compiler type when switching devices in accuracy mode (#33695)

Andrei Tamas608e3962ae92
diff --git a/src/plugins/intel_npu/tools/protopipe/main.cpp b/src/plugins/intel_npu/tools/protopipe/main.cpp
index e19197a5138..e059abeb838 100644
--- a/src/plugins/intel_npu/tools/protopipe/main.cpp
+++ b/src/plugins/intel_npu/tools/protopipe/main.cpp
@@ -191,7 +191,7 @@ static Simulation::Ptr createSimulation(const std::string& mode, StreamDesc&& st
std::move(stream.output_data_map), std::move(stream.per_iter_outputs_path)};
simulation = std::make_shared<ValSimulation>(std::move(cfg), std::move(opts));
} else if (mode == "accuracy") {
- AccuracySimulation::Options opts{FLAGS_reference_device, FLAGS_target_device, config.initializer,
+ AccuracySimulation::Options opts{FLAGS_reference_device, FLAGS_target_device, config.npu_compiler_type, config.initializer,
std::move(stream.initializers_map), std::move(stream.input_data_map),
std::move(stream.output_data_map), config.metric, std::move(stream.metrics_map)};
simulation = std::make_shared<AccuracySimulation>(std::move(cfg), std::move(opts));
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 1f081f31345..8a4664f6727 100644
--- a/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp
+++ b/src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp
@@ -879,6 +879,7 @@ Config parseConfig(const YAML::Node& node, const ReplaceBy& replace_by) {
Logger::global_lvl = toLogLevel(global_opts.log_level);
Config config;
+ config.npu_compiler_type = global_opts.compiler_type;
config.scenarios = parseScenarios(node["multi_inference"], global_opts, replace_by);
ASSERT(!config.scenarios.empty());
diff --git a/src/plugins/intel_npu/tools/protopipe/src/parser/parser.hpp b/src/plugins/intel_npu/tools/protopipe/src/parser/parser.hpp
index eb46e776e0d..0deb93fcfa5 100644
--- a/src/plugins/intel_npu/tools/protopipe/src/parser/parser.hpp
+++ b/src/plugins/intel_npu/tools/protopipe/src/parser/parser.hpp
@@ -40,6 +40,7 @@ struct Config {
IAccuracyMetric::Ptr metric;
bool disable_high_resolution_timer;
std::vector<ScenarioDesc> scenarios;
+ std::string npu_compiler_type;
};
struct ReplaceBy {
diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.cpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.cpp
index cc0675bf807..5190fb3b3ea 100644
--- a/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.cpp
+++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.cpp
@@ -503,10 +503,18 @@ bool PipelinedSimulation::process(cv::GStreamingCompiled& pipeline, DeviceType d
} // anonymous namespace
-static void changeDeviceParam(InferenceParamsMap& params, const std::string& device_name) {
+static void changeDeviceParam(InferenceParamsMap& params, const std::string& device_name, const std::string& npu_compiler_type) {
for (auto& [tag, inference_params] : params) {
if (auto* ov = std::get_if<OpenVINOParams>(&inference_params)) {
ov->device = device_name;
+
+ if (device_name == "NPU") {
+ if (ov->config.find("NPU_COMPILER_TYPE") == ov->config.end()) {
+ ov->config.emplace("NPU_COMPILER_TYPE", npu_compiler_type);
+ }
+ } else {
+ ov->config.erase("NPU_COMPILER_TYPE");
+ }
} else if (auto* onnx = std::get_if<ONNXRTParams>(&inference_params)) {
if (auto* ov_ep = std::get_if<ONNXRTParams::OpenVINO>(&onnx->ep)) {
ov_ep->params_map["device_type"] = device_name;
@@ -549,9 +557,9 @@ std::shared_ptr<PipelinedCompiled> AccuracySimulation::compilePipelined(DummySou
}
std::shared_ptr<PipelinedCompiled> AccuracySimulation::compilePipelined(const bool drop_frames) {
- changeDeviceParam(m_cfg.params, m_opts.tgt_device);
+ changeDeviceParam(m_cfg.params, m_opts.tgt_device, m_opts.npu_compiler_type);
auto tgt_compile_args = cv::compile_args(getNetworksPackage());
- changeDeviceParam(m_cfg.params, m_opts.ref_device);
+ changeDeviceParam(m_cfg.params, m_opts.ref_device, m_opts.npu_compiler_type);
auto ref_compile_args = cv::compile_args(getNetworksPackage());
// NB: Create separate sources for REF and TGT to avoid shared state issues.
@@ -587,9 +595,9 @@ std::shared_ptr<SyncCompiled> AccuracySimulation::compileSync(DummySources&& ref
}
std::shared_ptr<SyncCompiled> AccuracySimulation::compileSync(const bool drop_frames) {
- changeDeviceParam(m_cfg.params, m_opts.tgt_device);
+ changeDeviceParam(m_cfg.params, m_opts.tgt_device, m_opts.npu_compiler_type);
auto tgt_compile_args = cv::compile_args(getNetworksPackage());
- changeDeviceParam(m_cfg.params, m_opts.ref_device);
+ changeDeviceParam(m_cfg.params, m_opts.ref_device, m_opts.npu_compiler_type);
auto ref_compile_args = cv::compile_args(getNetworksPackage());
// NB: Create separate sources for REF and TGT to avoid shared state issues.
diff --git a/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.hpp b/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.hpp
index b754698b53e..8275946847b 100644
--- a/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.hpp
+++ b/src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.hpp
@@ -17,6 +17,7 @@ public:
struct Options {
std::string ref_device;
std::string tgt_device;
+ std::string npu_compiler_type;
IRandomGenerator::Ptr global_initializer;
ModelsAttrMap<IRandomGenerator::Ptr> initializers_map;
ModelsAttrMap<std::string> input_data_map;
diff --git a/src/plugins/intel_npu/tools/protopipe/version.hpp.in b/src/plugins/intel_npu/tools/protopipe/version.hpp.in
index 6c649be87e5..9e4fa68d43d 100644
--- a/src/plugins/intel_npu/tools/protopipe/version.hpp.in
+++ b/src/plugins/intel_npu/tools/protopipe/version.hpp.in
@@ -1,3 +1,3 @@
#pragma once
-#define APP_VERSION "v1.2.0-@GIT_SHA@"
+#define APP_VERSION "v1.2.1-@GIT_SHA@"