Skip to content

Commit 467abdd

Browse files
Copilotvraspar
andcommitted
Fix QNN error messages being logged as VERBOSE instead of ERROR
Co-authored-by: vraspar <51386888+vraspar@users.noreply.github.com>
1 parent 593bdfa commit 467abdd

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ void QnnLogging(const char* format,
407407
QnnLog_Level_t level,
408408
uint64_t timestamp,
409409
va_list argument_parameter) {
410-
ORT_UNUSED_PARAMETER(level);
411410
ORT_UNUSED_PARAMETER(timestamp);
412411

413412
if (!::onnxruntime::logging::LoggingManager::HasDefaultLogger()) {
@@ -417,7 +416,26 @@ void QnnLogging(const char* format,
417416
}
418417

419418
const auto& logger = ::onnxruntime::logging::LoggingManager::DefaultLogger();
420-
const auto severity = ::onnxruntime::logging::Severity::kVERBOSE;
419+
420+
// Map QNN log level to ORT severity
421+
logging::Severity severity;
422+
switch (level) {
423+
case QNN_LOG_LEVEL_VERBOSE:
424+
case QNN_LOG_LEVEL_DEBUG:
425+
severity = logging::Severity::kVERBOSE;
426+
break;
427+
case QNN_LOG_LEVEL_INFO:
428+
severity = logging::Severity::kINFO;
429+
break;
430+
case QNN_LOG_LEVEL_WARN:
431+
severity = logging::Severity::kWARNING;
432+
break;
433+
case QNN_LOG_LEVEL_ERROR:
434+
default:
435+
severity = logging::Severity::kERROR;
436+
break;
437+
}
438+
421439
const auto data_type = ::onnxruntime::logging::DataType::SYSTEM;
422440

423441
if (logger.OutputIsEnabled(severity, data_type)) {
@@ -491,6 +509,22 @@ QnnLog_Level_t QnnBackendManager::MapOrtSeverityToQNNLogLevel(logging::Severity
491509
}
492510
}
493511

512+
logging::Severity QnnBackendManager::MapQNNLogLevelToOrtSeverity(QnnLog_Level_t qnn_log_level) {
513+
// Map QNN log level to ORT log severity
514+
switch (qnn_log_level) {
515+
case QNN_LOG_LEVEL_VERBOSE:
516+
case QNN_LOG_LEVEL_DEBUG:
517+
return logging::Severity::kVERBOSE;
518+
case QNN_LOG_LEVEL_INFO:
519+
return logging::Severity::kINFO;
520+
case QNN_LOG_LEVEL_WARN:
521+
return logging::Severity::kWARNING;
522+
case QNN_LOG_LEVEL_ERROR:
523+
default:
524+
return logging::Severity::kERROR;
525+
}
526+
}
527+
494528
Status QnnBackendManager::ResetQnnLogLevel(std::optional<logging::Severity> ort_log_level) {
495529
std::lock_guard<std::recursive_mutex> lock(logger_recursive_mutex_);
496530
if (!backend_setup_completed_ || logger_ == nullptr) {

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ class QnnBackendManager : public std::enable_shared_from_this<QnnBackendManager>
288288
const char* QnnProfileErrorToString(QnnProfile_Error_t error);
289289
std::string QnnErrorHandleToString(Qnn_ErrorHandle_t error);
290290
QnnLog_Level_t MapOrtSeverityToQNNLogLevel(logging::Severity ort_log_level);
291+
logging::Severity MapQNNLogLevelToOrtSeverity(QnnLog_Level_t qnn_log_level);
291292
#ifdef _WIN32
292293
void LogQnnProfileEventAsTraceLogging(
293294
uint64_t timestamp,

0 commit comments

Comments
 (0)