已合并
test: 补充reg_func算子UT覆盖缺失分支(#210) #1953
test: 补充reg_func算子UT覆盖缺失分支(#210) #1953
已合并
Leechi666创建于 21 天前
Leechi666
Leechi666成员
21 天前

Pull Request

描述

补充 autofuse/ascir/reg_func 目录多个算子的单元测试,使得该目录下UT覆盖率本地自测达到95.7%覆盖此前未触达的分支(Issue #210 reg_func 部分第一批提交):

源文件 新增用例 覆盖分支 行覆盖率
remainder.cpp WhenSecondInputIsTensor 第二输入为普通 tensor 时的 3×dtype×size 计算 52.9% → 100%
reduce.cpp WhenNodeTypeIsArgMax / WhenNodeTypeIsArgMaxMultiRPhase1 ArgMax 系算子的多 tmp_buf 分配(生命周期 -1,0,1,2 / -1,0,1) 83.1% → 100%
truediv.cpp WhenSecondInputIsUbScalar HasScalarOrUbScalar 为 true 的默认大小路径 90.9% → 100%
compare.cpp WhenTwoAxesAndBf16Dtype 双向量化轴 + BF16 dtype 的默认大小回退 98.7% → 100%
default_reg_func.cpp / rsqrt.cpp WhenInputIsAllScalar GetInputDataSizeTmpBuffer 全标量输入的 fallback 98.6% → 100%

lcov 实测:六个文件合计 237/237 行、23/23 函数,100%。

变更类型

关联的Issue

#210

如何测试

  1. sh build.sh -u --module=autofuse_framework -j 8
  2. 运行 CalcRemainderTmpSizeTest / CalcReduceTmpSizeTest / CalcTrueDivTmpSizeTest / CalcCompareTmpSizeTest / CalcRsqrtTmpSizeTest 新增用例全部通过
  3. lcov 收集验证上述六个文件行覆盖率 100%

核对清单

其他信息

split.cpp 保持 94.7%(剩余 1 行为 IsAllStaticAligned 内层符号乘积,需要动态输出构图机制,投入产出比低);argmax/argmax_with_value/zerosLike 为无调用方的遗留死代码(12 行),建议另行确认删除。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Leechi666 的贡献)
Leechi666Leechi666成员
21 天前 创建了 pull request,commit 7dac3d8c
atomgit-bot
atomgit-bot
21 天前 评论:

变更摘要

本 PR 针对 Issue #210(autofuse/ascir 目录单测行覆盖率补足至 95%)中 reg_func 部分的首批提交,为 autofuse/tests/ut/ascir/reg_func/test_reg_func_remainder.cpp 新增用例 CalcRemainderTmpSize_ShouldReturnCorrectSize_WhenSecondInputIsTensor,覆盖 autofuse/ascir/reg_func/remainder.cpp 中「第二输入为普通 tensor」时按 3×dtype 字节数×输入元素数计算临时内存大小的分支,使该文件行覆盖率由 52.9% 提升至 100%(17/17 行)。

主要改动

  • 新增第二输入为 tensor 的测试用例: 在 CalcRemainderTmpSizeTest 中新增 CalcRemainderTmpSize_ShouldReturnCorrectSize_WhenSecondInputIsTensor,构造 Data/Load/Remainder/Store/Output 完整计算图,并显式设置 node->inputs[0].attr.vectorized_strides 以进入目标计算分支。
  • 构造非全 1 的 repeats 输入: 与既有用例不同,本用例让 x2Data(真张量)而非 Scalar,且 x2.y.repeatsload2.y.repeats 均设为 {s0, s1},使临时内存大小计算走「3 个中间 buffer × sizeof(float)× 输入元素数」的分支。
  • 断言临时内存大小的封顶语义: 用例断言 result[0]->size 等于 sym::Min(Symbol(65312), Symbol(12) * s0 * s1),即按 12×s0×s1(3×4 字节×元素数)计算并与上限 65312 取小,与 abs 测试的断言形式保持一致,同时校验 result.size() 为 1 且 life_time_axis_id 为 -1。
likedislike
不准确?
CANN-robot
CANN-robot成员
21 天前 评论:

Hi @hitLeechi, welcome to submitting your first PR to graph-autofusion!

PR Merge Steps

1. CLA Signing

If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.

2. CI Check

Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.

3. Code Review

After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.

likedislike
atomgit-bot
atomgit-bot
21 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
21 天前 添加了label:cann-cla/yes
此处折叠了76条消息 查看更多
liyuewei
liyuewei成员
17 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
17 天前 添加了label:lgtm
yangyongqiang
yangyongqiang成员
17 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
17 天前 添加了label:approved
CANN-robotCANN-robot成员
17 天前 合入了pull request