Commit ec4f6bf
[QNN EP] Fix error messages being logged as VERBOSE instead of ERROR (microsoft#24931)
## Problem
QNN error messages were being logged at VERBOSE level instead of ERROR
level, making them invisible unless verbose logging was enabled. Users
would only see unhelpful generic error messages like:
```
Failed to finalize QNN graph. Error code: 1002 at location qnn_model.cc:167 FinalizeGraphs
```
But the actual detailed error messages from QNN were hidden in verbose
logs:
```
tcm_migration.cc:2088:ERROR:Operator named q::*InputSlicePad (0x1654900000002) not sufficiently tiled to fit in TCM. Requires 12441600 bytes
graph_prepare.cc:2808:ERROR:Graph prepare TCM Migration action failed
graph_prepare.cc:2868:ERROR:Graph prepare failed during optimization with err: 17, Fatal Optimize
```
## Root Cause
The `QnnLogging` callback function in `qnn_backend_manager.cc` was
ignoring the `level` parameter from QNN and hardcoding all messages as
`kVERBOSE` severity:
```cpp
void QnnLogging(const char* format, QnnLog_Level_t level, uint64_t timestamp, va_list argument_parameter) {
ORT_UNUSED_PARAMETER(level); // ❌ Ignoring the actual log level
// ...
const auto severity = ::onnxruntime::logging::Severity::kVERBOSE; // ❌ Hardcoded as VERBOSE
```
## Solution
Modified the `QnnLogging` function to properly map QNN log levels to
appropriate ORT severity levels:
- `QNN_LOG_LEVEL_ERROR` → `logging::Severity::kERROR` ✅ **Key fix**
- `QNN_LOG_LEVEL_WARN` → `logging::Severity::kWARNING`
- `QNN_LOG_LEVEL_INFO` → `logging::Severity::kINFO`
- `QNN_LOG_LEVEL_VERBOSE/DEBUG` → `logging::Severity::kVERBOSE`
## Changes Made
1. **Modified `QnnLogging` function**: Removed hardcoded `kVERBOSE` and
added proper level mapping
2. **Added `MapQNNLogLevelToOrtSeverity` function**: For potential
future reuse
3. **Minimal and surgical changes**: Only 37 lines added, 2 removed
## Impact
QNN error messages will now appear as ERROR-level logs in normal logging
output, making debugging much easier for users without requiring verbose
logging to be enabled.
Fixes microsoft#24876.
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: vraspar <51386888+vraspar@users.noreply.github.com>
Co-authored-by: yuslepukhin <11303988+yuslepukhin@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <dmitrism@microsoft.com>1 parent 990ba5f commit ec4f6bf
2 files changed
Lines changed: 21 additions & 3 deletions
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | 444 | | |
446 | 445 | | |
447 | 446 | | |
| |||
451 | 450 | | |
452 | 451 | | |
453 | 452 | | |
454 | | - | |
| 453 | + | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
528 | 544 | | |
529 | 545 | | |
530 | 546 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
| |||
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
330 | | - | |
331 | 333 | | |
332 | 334 | | |
333 | 335 | | |
| |||
0 commit comments