Merged
增加对opType是否越界的校验 #803
ren-botaoAdd on Aug 31
增加对opType是否越界的校验 #803
Merged
Merged fromren-botao/opbaseop_type_max_checkintocann/opbasemaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for ren-botao's contribution.)atomgit-bot
Aug 31 Comments:
Aug 31 Comments:
变更摘要
本 PR 主要聚焦于对 opType(算子类型 ID)是否越界或未注册的校验增强。改动将上限常量 MAX_OP_TYPE_COUNT(值为 1024)统一定义到 kernel_utils.h,并在算子注册、AclOpKernelInit、InitOpFunctions、MemSet 与 NonFiniteCheck 等关键路径上补充了 opType == 0(未注册)或越界的检查,同时将原 kernel_mgr.cpp 中的 OP_LOGD 日志提升为 OP_LOGW 告警级别。
主要改动
- 统一定义上限常量:在
src/nnopbase/common/inc/kernel_utils.h新增MAX_OP_TYPE_COUNT = 1024,并从op_ctx_def.h中移除重复定义,避免同一常量多处声明。 - 强化
AclOpKernelInit校验:在kernel_mgr.cpp中将校验条件由opType >= MAX_OP_TYPE_COUNT扩展为opType >= MAX_OP_TYPE_COUNT || opType == 0,对未注册(id 为 0)的算子类型也予以拦截,并将日志级别从OP_LOGD提升为OP_LOGW。 InitOpFunctions增加越界检查:在op_run_context.cpp的InitOpFunctions入口新增CHECK_COND(opType < MAX_OP_TYPE_COUNT, ...),越界时返回ACLNN_ERR_INNER。MemSet与NonFiniteCheck增加未注册检查:分别在op_run_context.h与non_finite_check_op.h中通过OP_CHECK(opType != 0, ...)/OP_CHECK(opid != 0, ...)校验算子已注册,未注册时分别返回nullptr与ACLNN_ERR_INNER。- 注册端与查询端越界防护:在
op_def.cpp的OpTypeDict::Add中新增注册数量达到MAX_OP_TYPE_COUNT上限时拒绝注册并返回ACLNN_ERR_INNER的检查;同时在GetOpConfigJsonFileName中增加opType超出opConfigJsonPath_容量时返回空容器的越界保护。


Incorrect?
atomgit-bot
Aug 31 Comments:
Aug 31 Comments:
Aug 31 Added label: cann-cla/yes
CANN-robot
Aug 31 Comments:
Aug 31 Comments:
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 |
|---|---|---|
| repo-cann/opbase | ✅ 宋恺, pengjiahao96 (2/2) | ✅ 宋恺 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
ren-botao, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Aug 31 Set pengjiahao96,zhou-qilong,wangrui_,rxtfeng,loov1,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng as approver
Aug 31 Set pengjiahao96,zhou-qilong,wangrui_,rxtfeng,loov1,jia0liang,zl_hw,songkai111,pingchuantang,llimwang,gubaocheng as approver
19 event messages are collapsed here。 See more
Sep 1 Modify description of pull request
ren-botao
Sep 1 Comments:
Sep 1 Comments:
compile


Sep 1 Pre merge succeeded (commit_id: f58eed0ec7a68d2347c0485a0900dc8ab70fff90)
CANN-robot
Sep 1 Comments:
Sep 1 Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Sep 1 Added label: ci-pipeline-running
Sep 1 Removed label: ci-pipeline-running
Sep 1 Added label: ci-pipeline-passed
pengjiahao96
Sep 2 Comments:
Sep 2 Comments:
/lgtm


songkai111
Sep 2 Comments:
Sep 2 Comments:
/approve


Sep 2 Added label: lgtmapproved
Sep 2 Closed associated issue
Sep 2 Merged pull request
描述
本 PR 主要聚焦于对 opType(算子类型 ID)是否越界或未注册的校验增强。
关联的Issue
#347 (https://gitcode.com/cann/opbase/issues/347)
测试
增加了相关ut用例,冒烟验证
文档更新
不涉及
类型标签