Pull Request has been successfully merged by CANN-robot.
(Thank you for 刘奕哲's contribution.)变更摘要
本 PR 主要修复 TopK 的 RadixSelect 算法临时工作区(Temp Workspace)大小计算问题,避免临时空间不足导致内存踩踏:在 TiledTopKRadixSelect 中按输入数据类型字节宽度分别计算排序(sort)与 CalcTopK 阶段所需的临时块数,并以两者最大值作为临时 tensor 形状;同时新增了 NUM_VALUE_12、NUM_VALUE_22、NUM_VALUE_34、NUM_VALUE_256 等数值常量,重构了 RadixSelect 的代码生成单元测试以覆盖 INT16/FP32/INT64。PR 描述中还提到修复了 cbrt 文档渲染问题。
主要改动
- 按数据类型计算临时空间块数:新增
RadixSelectGetSortTempBlockCount与RadixSelectGetCalcTopKTempBlockCount两个函数,根据输入字节宽度(1/2、4、8)返回对应的临时块数,替换原先blockNum固定为 26(INT64 时为 46)的硬编码逻辑。 - 重构
TiledTopKRadixSelect临时空间计算:以按 128 对齐的 tile 维度tileAlign乘以块数得到calcTopKWorkspace与sortWorkspace,其中 CalcTopK 工作区还叠加分支工作区(NUM_VALUE_256 * BytesOf(DT_INT32) * NUM_VALUE_3与tileAlign * BytesOf(DT_INT32) * NUM_VALUE_2的较大值),最终临时形状取两者最大值,避免内存踩踏。 - 新增数值常量:在
operation_common.h中新增NUM_VALUE_12、NUM_VALUE_22、NUM_VALUE_34、NUM_VALUE_256常量,并将NUM_VALUE_46调整为NUM_VALUE_34,供新的临时空间计算使用。 - 重构 RadixSelect 单元测试:在
test_codegen_dyn_sort.cpp中将原TestRadixSelectFP32、TestRadixSelectInt64测试提取为公共辅助函数TestRadixSelect,并基于它新增TestRadixSelectInt16、TestRadixSelectFP32、TestRadixSelectInt64三个参数化测试用例。


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 |
|---|---|---|
| docs | ✅ lyz0328, 尹杰 (2/2) | ✅ lyz0328, 尹杰 (2/1) |
| framework/src/interface/operation | ✅ shi-dingkun, 尹杰 (2/2) | ✅ shi-dingkun, 尹杰 (2/1) |
| repo-cann/pypto | ✅ shi-dingkun, 尹杰 (2/2) | ✅ shi-dingkun, 尹杰 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Creeeeper, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/approve


描述
测试
完成自测以及冒烟测试
关联Issue
#3333
类型标签