Merged
Conversation
wangzhaode
reviewed
Mar 12, 2026
Collaborator
wangzhaode
left a comment
There was a problem hiding this comment.
PR #4239: Feature/qnnbugfix 代码审查
概述
QNN 后端增加 Transpose / Pack / Unpack 算子支持,同时修复节点名称冒号处理和 ONNX PReLU 单 slope 优化。整体思路合理,但有 2 个阻塞问题需修复。
🚨 阻塞问题
1. [Bug] QNNPermute.cpp — 移除 null 保护导致 OpType_Permute 可能崩溃
原始 onCreate 中有关键的空指针保护:
if (op->main_as_Permute()->dims() == nullptr) {
return nullptr;
}PR 中该检查被完全删除。如果一个 OpType_Permute 的 dims() 为 nullptr,onEncode 中会直接调用 param->dims()->size(),空指针解引用崩溃。这是回归 bug——原本能正常 fallback 的 case 现在会 crash。
建议:在 onCreate 中对 OpType_Permute 保留原有校验,或在 onEncode 的 Permute 分支加 null check。
2. [Bug] QNNConcat.cpp:15-27 — axis 变量可能未初始化
int axis;
if (mOp->type() == OpType_Concat) {
axis = ...;
} else if (mOp->type() == OpType_Pack) {
axis = ...;
} else if (mOp->type() == OpType_Unpack) {
axis = ...;
}
// 无 else 分支,axis 可能未初始化 → 未定义行为建议添加 else { MNN_ASSERT(false); return NOT_SUPPORT; }。
其他建议(非阻塞)
QNNPermute.cpp:38—inputs[1]->host<int32_t>()建议加空指针断言QNNConcat.cpp:19— early return 的 Reshape 路径在 axis 赋值之后,对 Pack 类型可能触发不必要的main_as_PackParam()调用,建议将 early return 前移- OnnxPrelu 单 slope 优化和节点名称冒号处理都是好的改进
Reviewed by claude-opus-4-6
wangzhaode
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
QNN 后端增加 Transpose / Pack / Unpack 算子