Skip to content

Commit 608e396

Browse files
authored
[Protopipe] Fix: Preserve NPU compiler type when switching devices in accuracy mode (#33695)
### Details: - *Store `npu_compiler_type` in `Config` and propagate through `AccuracySimulation::Options`* - *Update `changeDeviceParam()` to set/remove `NPU_COMPILER_TYPE` based on device* ### Tickets: - *EISW-199137*
1 parent 9636383 commit 608e396

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

src/plugins/intel_npu/tools/protopipe/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static Simulation::Ptr createSimulation(const std::string& mode, StreamDesc&& st
191191
std::move(stream.output_data_map), std::move(stream.per_iter_outputs_path)};
192192
simulation = std::make_shared<ValSimulation>(std::move(cfg), std::move(opts));
193193
} else if (mode == "accuracy") {
194-
AccuracySimulation::Options opts{FLAGS_reference_device, FLAGS_target_device, config.initializer,
194+
AccuracySimulation::Options opts{FLAGS_reference_device, FLAGS_target_device, config.npu_compiler_type, config.initializer,
195195
std::move(stream.initializers_map), std::move(stream.input_data_map),
196196
std::move(stream.output_data_map), config.metric, std::move(stream.metrics_map)};
197197
simulation = std::make_shared<AccuracySimulation>(std::move(cfg), std::move(opts));

src/plugins/intel_npu/tools/protopipe/src/parser/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ Config parseConfig(const YAML::Node& node, const ReplaceBy& replace_by) {
879879
Logger::global_lvl = toLogLevel(global_opts.log_level);
880880

881881
Config config;
882+
config.npu_compiler_type = global_opts.compiler_type;
882883
config.scenarios = parseScenarios(node["multi_inference"], global_opts, replace_by);
883884

884885
ASSERT(!config.scenarios.empty());

src/plugins/intel_npu/tools/protopipe/src/parser/parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct Config {
4040
IAccuracyMetric::Ptr metric;
4141
bool disable_high_resolution_timer;
4242
std::vector<ScenarioDesc> scenarios;
43+
std::string npu_compiler_type;
4344
};
4445

4546
struct ReplaceBy {

src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,18 @@ bool PipelinedSimulation::process(cv::GStreamingCompiled& pipeline, DeviceType d
503503

504504
} // anonymous namespace
505505

506-
static void changeDeviceParam(InferenceParamsMap& params, const std::string& device_name) {
506+
static void changeDeviceParam(InferenceParamsMap& params, const std::string& device_name, const std::string& npu_compiler_type) {
507507
for (auto& [tag, inference_params] : params) {
508508
if (auto* ov = std::get_if<OpenVINOParams>(&inference_params)) {
509509
ov->device = device_name;
510+
511+
if (device_name == "NPU") {
512+
if (ov->config.find("NPU_COMPILER_TYPE") == ov->config.end()) {
513+
ov->config.emplace("NPU_COMPILER_TYPE", npu_compiler_type);
514+
}
515+
} else {
516+
ov->config.erase("NPU_COMPILER_TYPE");
517+
}
510518
} else if (auto* onnx = std::get_if<ONNXRTParams>(&inference_params)) {
511519
if (auto* ov_ep = std::get_if<ONNXRTParams::OpenVINO>(&onnx->ep)) {
512520
ov_ep->params_map["device_type"] = device_name;
@@ -549,9 +557,9 @@ std::shared_ptr<PipelinedCompiled> AccuracySimulation::compilePipelined(DummySou
549557
}
550558

551559
std::shared_ptr<PipelinedCompiled> AccuracySimulation::compilePipelined(const bool drop_frames) {
552-
changeDeviceParam(m_cfg.params, m_opts.tgt_device);
560+
changeDeviceParam(m_cfg.params, m_opts.tgt_device, m_opts.npu_compiler_type);
553561
auto tgt_compile_args = cv::compile_args(getNetworksPackage());
554-
changeDeviceParam(m_cfg.params, m_opts.ref_device);
562+
changeDeviceParam(m_cfg.params, m_opts.ref_device, m_opts.npu_compiler_type);
555563
auto ref_compile_args = cv::compile_args(getNetworksPackage());
556564

557565
// 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
587595
}
588596

589597
std::shared_ptr<SyncCompiled> AccuracySimulation::compileSync(const bool drop_frames) {
590-
changeDeviceParam(m_cfg.params, m_opts.tgt_device);
598+
changeDeviceParam(m_cfg.params, m_opts.tgt_device, m_opts.npu_compiler_type);
591599
auto tgt_compile_args = cv::compile_args(getNetworksPackage());
592-
changeDeviceParam(m_cfg.params, m_opts.ref_device);
600+
changeDeviceParam(m_cfg.params, m_opts.ref_device, m_opts.npu_compiler_type);
593601
auto ref_compile_args = cv::compile_args(getNetworksPackage());
594602

595603
// NB: Create separate sources for REF and TGT to avoid shared state issues.

src/plugins/intel_npu/tools/protopipe/src/simulation/accuracy_mode.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class AccuracySimulation : public Simulation {
1717
struct Options {
1818
std::string ref_device;
1919
std::string tgt_device;
20+
std::string npu_compiler_type;
2021
IRandomGenerator::Ptr global_initializer;
2122
ModelsAttrMap<IRandomGenerator::Ptr> initializers_map;
2223
ModelsAttrMap<std::string> input_data_map;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#pragma once
22

3-
#define APP_VERSION "v1.2.0-@GIT_SHA@"
3+
#define APP_VERSION "v1.2.1-@GIT_SHA@"

0 commit comments

Comments
 (0)