Skip to content

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

[NPU] Add error handling for missing configuration file in parseConfigFile (#30134)

Wen Jie Seow64c920dfe495
diff --git a/src/plugins/intel_npu/tools/compile_tool/main.cpp b/src/plugins/intel_npu/tools/compile_tool/main.cpp
index da2e0db9104..e6a957050e9 100644
--- a/src/plugins/intel_npu/tools/compile_tool/main.cpp
+++ b/src/plugins/intel_npu/tools/compile_tool/main.cpp
@@ -370,6 +370,13 @@ static std::map<std::string, std::string> parseConfigFile(char comment = '#') {
std::map<std::string, std::string> config;
std::ifstream file(FLAGS_c);
+
+ // Check if the file exists, throws exception if it doesn't
+ if (!file.is_open() && !FLAGS_c.empty()) {
+ throw std::runtime_error("[ERROR] Configuration file " + FLAGS_c + " cannot be opened. " +
+ "Check if the file path is correct and that the file exists");
+ }
+
if (file.is_open()) {
std::string option;
while (std::getline(file, option)) {