Skip to content
20 changes: 18 additions & 2 deletions onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ void QnnLogging(const char* format,
QnnLog_Level_t level,
uint64_t timestamp,
va_list argument_parameter) {
ORT_UNUSED_PARAMETER(level);
ORT_UNUSED_PARAMETER(timestamp);

if (!::onnxruntime::logging::LoggingManager::HasDefaultLogger()) {
Expand All @@ -451,7 +450,8 @@ void QnnLogging(const char* format,
}

const auto& logger = ::onnxruntime::logging::LoggingManager::DefaultLogger();
const auto severity = ::onnxruntime::logging::Severity::kVERBOSE;
// Map QNN log level to ORT severity
logging::Severity severity = QnnBackendManager::MapQNNLogLevelToOrtSeverity(level);
const auto data_type = ::onnxruntime::logging::DataType::SYSTEM;

if (logger.OutputIsEnabled(severity, data_type)) {
Expand Down Expand Up @@ -525,6 +525,22 @@ QnnLog_Level_t QnnBackendManager::MapOrtSeverityToQNNLogLevel(logging::Severity
}
}

/* static */ logging::Severity QnnBackendManager::MapQNNLogLevelToOrtSeverity(QnnLog_Level_t qnn_log_level) {
// Map QNN log level to ORT log severity
switch (qnn_log_level) {
case QNN_LOG_LEVEL_VERBOSE:
case QNN_LOG_LEVEL_DEBUG:
return logging::Severity::kVERBOSE;
case QNN_LOG_LEVEL_INFO:
return logging::Severity::kINFO;
case QNN_LOG_LEVEL_WARN:
return logging::Severity::kWARNING;
case QNN_LOG_LEVEL_ERROR:
default:
return logging::Severity::kERROR;
}
}

Status QnnBackendManager::ResetQnnLogLevel(std::optional<logging::Severity> ort_log_level) {
std::lock_guard<std::recursive_mutex> lock(logger_recursive_mutex_);
if (!backend_setup_completed_ || logger_ == nullptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class QnnBackendManager : public std::enable_shared_from_this<QnnBackendManager>
const char* QnnProfileErrorToString(QnnProfile_Error_t error);
std::string QnnErrorHandleToString(Qnn_ErrorHandle_t error);
QnnLog_Level_t MapOrtSeverityToQNNLogLevel(logging::Severity ort_log_level);
static logging::Severity MapQNNLogLevelToOrtSeverity(QnnLog_Level_t qnn_log_level);

// Adds a new QNN context.
// Transfers ownership of `context_handle` (i.e., responsibility of freeing it) to this instance
Expand Down
Loading