已合并
增加mesw算子空指针校验 #9580
wuyufei创建于 8月31日
增加mesw算子空指针校验 #9580
已合并
wuyufei创建于 8月31日
wuyufei成员
8月31日

描述

本 PR 为 matmul_emu_split_weight(mesw)算子增加空指针校验,防止在推理 shape 与 tiling 阶段因属性指针或输入/输出描述为空而直接解引用导致崩溃。改动覆盖了算子的 infershape 与 arch35 tiling 两条路径:在解引用属性指针前先获取指针并判空,同时新增统一的输入非空校验流程并接入 GetShapeAttrsInfo() 主流程。

关联的Issue

https://gitcode.com/cann/ops-nn/issues/5475

测试

文档更新

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 wuyufei 的贡献)
Wwuyufei成员
8月31日 创建了 pull request,commit 811490b4
atomgit-bot
atomgit-bot
8月31日 评论:

变更摘要

本 PR 为 matmul_emu_split_weight(mesw)算子增加空指针校验,防止在推理 shape 与 tiling 阶段因属性指针或输入/输出描述为空而直接解引用导致崩溃。改动覆盖了算子的 infershape 与 arch35 tiling 两条路径:在解引用属性指针前先获取指针并判空,同时新增统一的输入非空校验流程并接入 GetShapeAttrsInfo() 主流程。

主要改动

  • InferShapeForMatmulEmuSplitWeight 属性指针判空:在 matmul_emu_split_weight_infershape.cpp 中,将原先直接解引用 attrs->GetAttrPointer<bool> 获取 transX/transW 的方式改为先取指针,用 OP_CHECK_IF 校验两个指针均非空后再取值,为空时上报 CUBE_INNER_ERR_REPORT 并返回 GRAPH_FAILED,避免空指针解引用。

  • ExtractAttrs 中 wLowScale 属性判空:在 matmul_emu_split_weight_tiling.cpp 的 ExtractAttrs() 中,对 INDEX_ATTR_W_LOW_SCALE 的属性指针先判空(通过 OP_TILING_CHECK),为空时返回 GRAPH_FAILED,再解引用赋值给 scale_。

  • 新增 ValidateInputsNotNull() 输入校验方法:在 matmul_emu_split_weight_tiling.cpp 中新增该方法,使用 OPS_CHECK_NULL_WITH_CONTEXT 依次校验 context_、attrs、输入 INDEX_X/INDEX_W_HIGH/INDEX_W_LOW 的 desc 与 shape,以及输出 INDEX_Y 的 desc 与 shape;并在 matmul_emu_split_weight_tiling.h 中声明该私有方法。

  • GetShapeAttrsInfo() 接入校验流程:在 GetShapeAttrsInfo() 中于 ExtractAttrs() 之前先调用 ValidateInputsNotNull(),校验失败即返回 GRAPH_FAILED,保证后续取属性、形状等操作在输入合法的前提下进行。

likedislike
不准确?
atomgit-bot
atomgit-bot
8月31日 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
8月31日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
8月31日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
matmul ✅ 商晓波, 林鹏翔 (2/2) ✅ 商晓波 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

wuyufei, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
8月31日 将zengjuan,sxb154714,chaotang233,crystalhu,yangyang016,fanqirui,chenqi317,LinPX,liubo75,tangweiwei2,wangzitao_leo,xubinglin,pingchuantang,liuyang_806设为评审人
CANN-robotCANN-robot成员
8月31日 将sxb154714,chaotang233,yangyang016,fanqirui,chenqi317,LinPX,tangweiwei2,wangzitao_leo,xubinglin,liuyang_806设为审查人
Wwuyufei成员
8月31日 修改了pull request 的描述
yuning_chen
yuning_chen成员
9月1日 评论:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!

likedislike
Wwuyufei成员
9月1日 修改了pull request 的描述
wuyufei成员
9月1日 评论:

compile

likedislike
Wwuyufei成员
9月1日 预合并成功(commit_id: 306efa1dd45044e7ad15c42886b57fb27601510b)
CANN-robotCANN-robot成员
9月1日 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月1日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月1日 添加了label:ci-pipeline-passed
yuning_chen
yuning_chen成员
9月1日 评论:

您好,pr合入已准备就绪,请尽快联系committer进行检视,谢谢!

likedislike
sxb154714
sxb154714成员
9月2日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
9月2日 添加了label:approved
林鹏翔成员9月2日进行代码检视2
matmul/matmul_emu_split_weight/op_host/op_tiling/arch35/matmul_emu_split_weight_tiling.cpp
@@ -189,1 +192,4 @@
189192 
193+// ====== Input null-check ======
194+ 
195+ge::graphStatus MatmulEmuSplitWeightTiling::ValidateInputsNotNull()
林鹏翔9月2日评论:

PR 描述的测试字段是空的,本次新增的三处校验(infershape 的 transX/transW 判空、tiling 的 scale 判空、ValidateInputsNotNull 整条链)都没有用例验证。建议至少补一个属性指针为 null 时走报错分支的 UT 用例,否则这些校验逻辑本身没有回归保护,后续改动容易把判空条件改丢。

likedislike
林鹏翔成员
9月2日 评论:

后续补齐UT

林林鹏翔成员
9月2日 解决了最后一个问题
林鹏翔成员
9月2日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
9月2日 添加了label:lgtm
CANN-robotCANN-robot成员
9月2日 合入了pull request
CANN-robot
CANN-robot成员
9月2日 评论:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike