已合并
补充StatelessUniform UT #4405
huairuchen创建于 17 天前
补充StatelessUniform UT #4405
已合并
huairuchen创建于 17 天前
huairuchen
huairuchen成员
17 天前

描述

补充StatelessUniform的opapi和infershape的UT

关联的Issue

https://gitcode.com/cann/ops-math/issues/2489

测试

成功通过新增21个UT测试,同时已有的11个ophost和4个opkernel测试也同样测试通过。

文档更新

类型标签

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

变更摘要

此 PR 为 StatelessUniform 算子补充了两个单元测试文件,覆盖 L0 算子的 API 调用路径与 InferShape 逻辑。新增的 test_aclnn_stateless_uniform_l0.cppl0op::StatelessUniform 的标量重载(A)和 Tensor 重载(B)共 6 条 dtype 分支(fp16/bf16/float32)进行了验证,并附加了多维输入、负值区间、非零 seed、dtype 保持等场景。新增的 test_stateless_uniform_infershape.cpp 则针对 CommonInferShape 中的 HandleShapeTensor<int64_t> / HandleShapeTensor<int32_t> 分支、const data 缺失时的 unknown shape 回退、以及非法 shape dtype 导致的 GRAPH_FAILED 路径提供了覆盖。

主要改动

  • 新增 L0 API 测试文件 test_aclnn_stateless_uniform_l0.cpp:通过 StatelessUniformL0Test 测试夹具分别验证标量接口与 Tensor 接口在 ACL_FLOATACL_FLOAT16ACL_BF16 三种输入 dtype 下的输出 dtype 正确性,并附加覆盖了多维 shape 保持、负值 from/to 区间、非零 seed/offset 和 dtype 不被静默提升等边界场景。
  • 新增 InferShape 测试文件 test_stateless_uniform_infershape.cpp:通过 StatelessUniformInferShapeTest 测试类,使用 InfershapeContextPara 构造不同 rank 的 shape tensor(1D/2D/4D/含1维度),验证 CommonInferShape 逐维写入输出 shape 的正确性,同时覆盖了 DT_INT32 shape tensor 分支和 DT_FLOAT 非法 dtype 触发 GRAPH_FAILED 的路径。
  • 覆盖 InferShape 的 unknown shape 回退路径:新增 case_null_const_1dcase_null_const_2d 两个用例,模拟 shape tensor 的 const data 为 nullptrSetUnknownShape 产生 {-1} / {-1, -1} 的输出 shape。
likedislike
atomgit-bot
atomgit-bot
17 天前 评论:

代码审查


审查总结

已审查全部 2 个变更文件:

  • random/stateless_uniform/tests/ut/op_api/test_aclnn_stateless_uniform_l0.cpp:发现 2 个问题(1 个 P2 资源泄漏,1 个 P3 可选改进)。
  • random/stateless_uniform/tests/ut/op_host/test_stateless_uniform_infershape.cpp:发现 2 个问题(均为 P2,涉及 case 8/9 的 nullptr 路径未触发和缓冲区大小不匹配)。
优先级 数量
P0 0
P1 0
P2 3
P3 1

总体风险评估:该变更新增了 StatelessUniform 算子的 L0 和 InferShape 单元测试,覆盖较全面。主要问题集中在:op_api 测试文件存在 aclTensor 资源泄漏(每个测试用例泄漏 1~4 个 tensor),以及 infershape 测试中两个 "null const data" 用例因使用空 vector 的 data() 而非 nullptr,未能可靠验证目标代码路径,且存在 shape 声明与缓冲区大小不一致的越界风险。除上述问题外,未发现安全漏洞、数据损坏或严重逻辑错误。建议在合入前修复 P2 问题。

类型 数量
🔴 阻塞 0
🟡 建议 3

💬 仅评论

likedislike
CANN-robotCANN-robot成员
17 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
17 天前 评论:

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
repo-cann/ops-math xuejinghui, 宋恺 (2/2) xuejinghui, 宋恺 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
此处折叠了44条消息 查看更多
Ssongkai111成员
17 天前 添加了 squash commit 备注:/approve
songkai111成员
17 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
17 天前 添加了label:lgtm
CANN-robotCANN-robot成员
17 天前 关闭了关联的issue
CANN-robotCANN-robot成员
17 天前 合入了pull request