已合并
整数attr获取风险整改 #2725
zhangqijia1创建于 3月16日
整数attr获取风险整改 #2725
已合并
zhangqijia1创建于 3月16日
zhangqijia1
3月16日

描述

部分算子的infershape和tiling中获取算子整型的属性用int类型或者int32_t类型,相关接口的属性使用int64_t存储,用int获取,存在数据截断的风险。需要整改。

关联的Issue

#1507

测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhangqijia1 的贡献)
Zzhangqijia1
3月16日 创建了 pull request,commit 1810e980
CANN-robot
CANN-robot成员
3月16日 评论:

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


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
index crystalhu, FelixTang7 (2/2) crystalhu (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
3月16日 将FelixTang7,crystalhu,fanqirui,zhou-qilong,chenqi317,liubo75,tangweiwei2,wangyongguang,zhang-wu设为评审人
CANN-robotCANN-robot成员
3月16日 将FelixTang7,crystalhu,zhou-qilong,chenqi317,liubo75,tangweiwei2,wangyongguang,zhang-wu设为审查人
zhangqijia1
3月16日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月16日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
3月16日 评论:

🔵 source code change are detected, tasks labels is removed in this pull request!

likedislike
CANN-robotCANN-robot成员
3月16日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月16日 评论:

流水线任务触发成功
任务链接 [bd961b635511454a8b4ee1f0634299a8][流水线指导]

任务名称状态日志下载链接
解析CI分支 ✅ SUCCESS
codecheck ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>

[2026-03-16 10:04:57]    CI执行结束

likedislike
CANN-robot
CANN-robot成员
3月16日 评论:

问题/功能描述

本次PR修复了多个算子在从属性(Attr)读取整型数据时存在的类型不匹配问题。具体包括:EmbeddingBagLinearIndexNonZero算子读取int64_t属性时错误使用了intint32_t指针,以及ScatterElementsV2算子在tiling实现中读取轴(axis)参数时使用了int类型。这些问题可能导致在64位系统或处理大维度数据时发生数据截断、解释错误或精度丢失,从而引发算子行为异常或计算错误。

修改方案描述

统一将相关算子中从属性读取整型值的代码更正为使用int64_t指针或类型。具体修改涉及EmbeddingBag算子的padding_idx属性、LinearIndex算子的dim属性、NonZero算子的dst_type属性,以及ScatterElementsV2算子在InitCacheOpSupportRunCacheOpTiling等多个函数中读取轴参数的代码。此修改确保了属性读取与算子定义中声明的int64_t类型严格一致,消除了潜在的数据截断风险,提升了代码的健壮性、跨平台兼容性以及对大维度输入的支持能力。

likedislike
CANN-robotCANN-robot成员
3月16日 添加了label:api-check-pass
此处折叠了5条事件消息 查看更多
CANN-robotCANN-robot成员
3月16日 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
3月16日 评论:

Notification

This pull request source branch has changed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robot
CANN-robot成员
3月16日 评论:

🔵 source code change are detected, tasks labels is removed in this pull request!

likedislike
zhangqijia1
3月16日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月16日 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月16日 删除了label:api-check-pass
CANN-robot
CANN-robot成员
3月16日 评论:

流水线任务触发成功
任务链接 [e6d19c449f4047e096e1476dfc143003][流水线指导]

任务名称状态日志下载链接
解析CI分支 ✅ SUCCESS
codecheck ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_950 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_950 ✅ SUCCESS >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>
Pre_Compile ✅ SUCCESS
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_950_ubuntu24 ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_950_ubuntu24 ✅ SUCCESS >>>>>
UT_Test_ophost ✅ SUCCESS
UT_Test_opapi ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
UT_Test_opgraph ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>

[2026-03-16 14:40:49]    CI执行结束

likedislike
CANN-robotCANN-robot成员
3月16日 添加了label:api-check-pass
CANN-robotCANN-robot成员
3月16日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月16日 添加了label:ci-pipeline-passed
Zzhangqijia1
3月16日 关联了issue:获取整型属性潜在风险整改
Zzhangqijia1
3月16日 修改了pull request 的描述
FelixTang7成员
3月17日 评论:

/lgtm

likedislike
胡碧霞成员
3月17日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
3月17日 添加了label:lgtmapproved
CANN-robot
CANN-robot成员
3月17日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: crystalhu.
Reviewers who wrote a comment of /lgtm are: crystalhu, FelixTang7.

likedislike
CANN-robotCANN-robot成员
3月17日 合入了pull request