已合并
fix: align multinomial sampling with normalized probabilities #4500
fenglin28创建于 28 天前
fix: align multinomial sampling with normalized probabilities #4500
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 fenglin28 的贡献)atomgit-bot
28 天前 评论:
28 天前 评论:
变更摘要
此PR在 stateless_sample_multinomial_impl.h 的 SimtUniform 内核函数中新增了对多项分布累积概率的校验逻辑,通过引入 asc_assert.h 并添加 assert 断言,确保在二分查找之前累积分布数组的最后一个元素(即总累积概率)大于零,防止无效分布数据导致未定义行为。
主要改动
- 新增
asc_assert.h头文件引入:在stateless_sample_multinomial_impl.h中添加了#include "utils/debug/asc_assert.h",为后续断言提供assert宏支持。 - 新增累积分布有效性断言:在
SimtUniform函数的二分查找循环之前,添加了assert(x[numCat - 1] > static_cast<XT>(0)),用于在运行时校验多项分布的累积分布数组末尾元素大于零,确保分布数据合法。


atomgit-bot
28 天前 评论:
28 天前 评论:
28 天前 添加了label:cann-cla/yes
CANN-robot
28 天前 评论:
28 天前 评论:
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 |
|---|---|---|
| */*/README.md | ✅ 蔡雯雯, 顾宝成, 王瑞 (3/2) | ✅ 蔡雯雯 (1/1) |
| */*/docs/acl*.md | ✅ 蔡雯雯, 王瑞, 顾宝成 (3/2) | ✅ 蔡雯雯 (1/1) |
| */*/op_api/*.h | ✅ 汤磊, 顾宝成, 王瑞 (3/2) | ✅ 汤磊 (1/1) |
| */*/op_host/*_def.cpp | ✅ 汤磊, 王瑞, 顾宝成 (3/2) | ✅ 汤磊 (1/1) |
| repo-cann/ops-math | ✅ 王瑞, 顾宝成 (2/2) | ✅ 王瑞 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
fenglin28, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了266条消息 查看更多
tang-lei01
9 天前 评论:
9 天前 评论:
/approve


CANN-robot
9 天前 评论:
9 天前 评论:
The following users do not have permission to comment /lgtm or /approve on any module in this PR:
zhouwenfang


9 天前 添加了label:approved
9 天前 关闭了关联的issue
9 天前 合入了pull request
描述
修复 StatelessSampleMultinomial 边界场景下的采样行为:
norm_probs,用于准确判断零概率类别norm_probs存在时,使用x执行二分查找,使用norm_probs处理零概率类别回退;缺省时保留基于相邻 CDF 值的兼容路径x的维度校验,以及x与norm_probs的形状一致性校验关联的Issue
https://gitcode.com/cann/ops-math/issues/2558
测试
完整通过 UT、泛化 ST 及流水线验证
文档更新
更新 README 中
x和norm_probs的输入及约束说明类型标签