已合并
fix: 修复 Gather 回绕及 BrcInline/Cast/Concat 截断(#256 #258 #259 #260) #1862
m0_56712298创建于 8月28日
fix: 修复 Gather 回绕及 BrcInline/Cast/Concat 截断(#256 #258 #259 #260) #1862
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 m0_56712298 的贡献)8月28日 创建了 pull request,commit d6923a63
8月28日 关联了issue:【缺陷报告】整数溢出(含上溢出/下溢出) - 文件gather.h - 函数DataCopySimdSimt - 行号484,【缺陷报告】数据类型截断 - 文件brc_inline_api.h - 函数BinaryBrcInlineApiWithTwoVectorizedAxis - 行号43,【缺陷报告】数据类型截断 - 文件cast.h - 函数CastExtendWithMaskMode - 行号134,【缺陷报告】数据类型截断 - 文件concat.h - 函数GenMaskReg - 行号256
8月28日 关联了issue:【缺陷报告】整数溢出(含上溢出/下溢出) - 文件gather.h - 函数DataCopySimdSimt - 行号484,【缺陷报告】数据类型截断 - 文件brc_inline_api.h - 函数BinaryBrcInlineApiWithTwoVectorizedAxis - 行号43,【缺陷报告】数据类型截断 - 文件cast.h - 函数CastExtendWithMaskMode - 行号134,【缺陷报告】数据类型截断 - 文件concat.h - 函数GenMaskReg - 行号256
atomgit-bot
8月28日 评论:
8月28日 评论:
变更摘要
本 PR 集中修复 AscendC 算子 API 的四个缺陷(#256、#258、#259、#260):一是修复 v35 DataCopySimdSimt 在目的地址未按 32 字节对齐时,padding 分支的无符号长度回绕问题;二是修复 BrcInline 与 Cast 的 repeat stride 经 uint8_t 窄化导致的截断问题;三是修复 Concat 的 GenMaskReg tail mask 经 uint16_t 窄化导致的高 16 位丢失问题。四个修复均为纯代码级 bug 修复,不涉及 API/ABI、图改写或运行时接口变更,并各自补充了针对性的单元/回归测试。
主要改动
- 修复 Gather 未对齐 padding 分支的无符号回绕:
DataCopySimdSimt的 padding 分支改为仅复制min(length, padding_elements)个实际元素;当length <= padding_elements时复制完成后直接返回,否则先推进dst_p/src_p并扣减length,避免无符号减法回绕导致异常行为。 - 修复 BrcInline repeat stride 截断:
BinaryBrcInlineApiWithTwoVectorizedAxis先以int64_t计算repeat_stride_in_blocks,当超出 255 blocks 时回退到既有 counter 循环路径,可表示范围内才窄化为uint8_t继续走 repeat 快路径。 - 修复 Cast repeat stride 截断:
CastExtendWithMaskMode先以uint32_t计算输入、输出 repeat stride,任一超过MAX_REPEAT_TIMES时按行调用普通AscendC::Cast路径,可表示范围内再窄化为uint8_t。 - 修复 Concat tail mask 高 16 位丢失:
GenMaskReg将tail_mask由uint16_t改为uint32_t,避免写入 mask word 前高 16 位被截断。 - 新增回归测试:新增
test_gather.cpp(未对齐小长度场景,校验目标元素正确且缓冲区其余元素未被写入),并在test_brc_inline_api.cpp、test_cast.cpp、test_concat.cpp中新增用例,分别校验 counter 路径回退、两行输出位置及 padding 区域未额外写入、8 个uint32_tmask word 的高位保留。


不准确?
atomgit-bot
8月28日 评论:
8月28日 评论:
8月28日 添加了label:stat/needs-squash
此处折叠了78条消息 查看更多
wangxiaotian995
26 天前 评论:
26 天前 评论:
/lgtm


26 天前 添加了label:lgtm
yangyongqiang
25 天前 评论:
25 天前 评论:
/approve


25 天前 添加了label:approved
25 天前 合入了pull request
Pull Request
描述
修复 v35 AscendC
DataCopySimdSimt在目的地址未按 32 字节对齐时的无符号长度回绕问题。min(length, padding_elements)个实际元素。length <= padding_elements时完成实际元素复制后直接返回,避免无符号减法回绕。同时修复 Issue #258 中 BrcInline repeat stride 的
uint8_t截断问题。同时修复 Issue #259 中 Cast repeat stride 的
uint8_t截断问题。uint32_t计算输入、输出 repeat stride,避免窄化后再判断。同时修复 Issue #260 中 Concat tail mask 的
uint16_t截断问题。uint32_t保存 32 位 tail mask,避免写入 mask word 前丢失高 16 位。GenMaskReg高位保留回归测试,直接校验 8 个uint32_tmask word。变更类型
请选择本次引入的变更类型:
关联的Issue
GitCode 每个 PR 仅允许正式关联一个 Issue,因此保留原 #256 的正式关联,并在此记录 #258、#259、#260。
如何测试
描述测试此变更的步骤和前提条件:
cmake --build build --target test_ascendc_api_v35 -j 8:通过。test_ascendc_api_v35 --gtest_filter=TestApiGather.DataCopySimdSimtSmallLengthWithinPadding --gtest_brief=1:1/1 通过。test_ascendc_api_v35 --gtest_brief=1:352/352 通过。bash scripts/oat_check.sh:#256 的三个变更文件检查通过。test_ascendc_api --gtest_filter=TestApiBroInline.*:15/15 通过。bash scripts/oat_check.sh autofuse/ascendc/api/brc_inline_api.h autofuse/tests/ut/ascendc/api/test_brc_inline_api.cpp:#258 的两个变更文件检查通过。test_ascendc_api --gtest_filter=TestApiCast.LargeDstRepeatStrideFallsBackToLoop:1/1 通过。test_ascendc_api --gtest_filter='*Cast*':43/43 通过。test_ascendc_api:456/456 通过。bash scripts/oat_check.sh autofuse/ascendc/api/cast.h autofuse/tests/ut/ascendc/api/test_cast.cpp:#259 的两个变更文件检查通过。cmake --build build --target test_ascendc_api_v35 -j 8:#260 增量编译通过。test_ascendc_api_v35 --gtest_filter='RegbaseApiConcatTest.*':2/2 通过。bash scripts/oat_check.sh autofuse/v35/ascendc/api_regbase/concat.h autofuse/tests/v35/ut/ascendc/api_regbase/test_concat.cpp:#260 的两个变更文件检查通过。核对清单
其他信息
本次 PR 包含 #256、#258、#259 和 #260 四个独立
fix:commit,不涉及 API/ABI、图改写、构建交付或运行时接口变更。