已开启
【代码侦探Challenge04-DivCustomTemplate】新增DivCustomTemplate工程化算子开发实现 #2154
luoxiaoyan2024创建于 5 天前
【代码侦探Challenge04-DivCustomTemplate】新增DivCustomTemplate工程化算子开发实现 #2154
已开启
合并受阻
5 天前 创建了 pull request,commit 5acfb8c2
atomgit-bot
5 天前 评论:
5 天前 评论:
变更摘要
本 PR 实现 Challenge04-DivCustomTemplate 工程化算子开发任务,新增矢量除法算子 DivCustomTemplate(计算 z = x / y,仅支持 float16),通过 msopgen 生成算子工程,完整覆盖 op_host tiling、op_kernel 核函数与 ACLNN 单测验证流程。
主要改动
- 核函数实现:新增
op_kernel/div_custom_template.cpp,定义KernelDiv模板类,采用GlobalTensor/LocalTensor/TQue与双缓冲(BUFFER_NUM=2)管理数据,按 CopyIn→Compute→CopyOut 范式用DataCopy搬运、Div指令计算;通过 tile 循环(TILE_LENGTH=2048)加尾块处理支持任意 shape,最后一个 block 负责处理余数 - Host tiling 逻辑:新增
op_host/div_custom_template.cpp,TilingFunc用int64_t计算元素总数避免溢出并写入 tiling 数据,SetBlockDim(8)设置 8 个核;InferShape/InferDataType使输出 shape 与数据类型与输入一致 - Tiling 数据结构:新增
op_host/div_custom_template_tiling.h,通过BEGIN_TILING_DATA_DEF定义DivCustomTemplateTilingData,包含size(uint32_t)字段并注册 tiling 数据类 - 算子定义文件:新增
div_custom_template.json,声明x、y两个 required 输入与z输出,均为float16、ND格式 - 工程化构建与验证:新增
run.sh自动化脚本(加载 CANN 环境、msopgen gen生成工程、编译安装算子、编译并运行测试)与test/main.cppACLNN 测试用例,通过aclnnDivCustomTemplate验证1.0 / 2.0 = 0.5并输出test pass


atomgit-bot
5 天前 评论:
5 天前 评论:
5 天前 添加了label:stat/needs-squash
5 天前 添加了label:cann-cla/yes
CANN-robot
5 天前 评论:
5 天前 评论:
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.
For more, you also can visit HICANN.
PR Approval Progress
⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/cann-outreach | ❌ (0/2)(You can also ask: Carolina_yuan, 田晓亮, luzx66, shaoyf, 王艳秋) | ❌ (0/1)(You can also ask: luzx66, 傅涛, jxlang, gcw_tgPdOLZT, 田晓亮) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
luoxiaoyan2024, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Lluoxiaoyan2024
5 天前 update merge request[project id: 9865789, iid: 2154, commit_id: b6013e71e17ee5220b6f4b8f2beedeb101676d09] virtual merging success
5 天前 update merge request[project id: 9865789, iid: 2154, commit_id: b6013e71e17ee5220b6f4b8f2beedeb101676d09] virtual merging success
Lluoxiaoyan2024
5 天前 强制推送 1 个提交:ba437de0-[Challenge04-DivCustomTemplate] 新增DivCustomTemplate工程化算子开发实现\n\n- 使用msopgen生成算子工程(ai_core-ascend910a,适配Ascend910硬件)\n- 实现op_kernel核函数:使用GlobalTensor/LocalTensor/TQue管理数据,DataCopy搬运,Div计算z=x/y,tile循环+尾块处理支持任意shape\n- 实现op_host tiling逻辑:int64_t计算元素总数避免溢出,SetBlockDim(8),dtype声明与kernel一致(仅float16)\n- 通过ACLNN接口验证test pass(x=1.0, y=2.0, z=0.5)\n\nCo-authored-by: luoxiaoyan2024
5 天前 强制推送 1 个提交:ba437de0-[Challenge04-DivCustomTemplate] 新增DivCustomTemplate工程化算子开发实现\n\n- 使用msopgen生成算子工程(ai_core-ascend910a,适配Ascend910硬件)\n- 实现op_kernel核函数:使用GlobalTensor/LocalTensor/TQue管理数据,DataCopy搬运,Div计算z=x/y,tile循环+尾块处理支持任意shape\n- 实现op_host tiling逻辑:int64_t计算元素总数避免溢出,SetBlockDim(8),dtype声明与kernel一致(仅float16)\n- 通过ACLNN接口验证test pass(x=1.0, y=2.0, z=0.5)\n\nCo-authored-by: luoxiaoyan2024
Lluoxiaoyan2024
5 天前 update merge request[project id: 9865789, iid: 2154, commit_id: 544ae0a8369cb8b180779487ca2d69f219edf233] virtual merging success
5 天前 update merge request[project id: 9865789, iid: 2154, commit_id: 544ae0a8369cb8b180779487ca2d69f219edf233] virtual merging success
5 天前 删除了label:cann-cla/yes
5 天前 删除了label:stat/needs-squash
CANN-robot
5 天前 评论:
5 天前 评论:
5 天前 添加了label:cann-cla/yes
变更描述 / Description
本PR实现Challenge04-DivCustomTemplate工程化算子开发任务,完成矢量除法算子
z = x / y的工程化开发。实现内容
msopgen生成算子工程:
msopgen gen -c ai_core-ascend910a(SoC型号Ascend910PremiumA)op_kernel核函数 (
op_kernel/div_custom_template.cpp):GlobalTensor/LocalTensor/TQue管理数据,双缓冲(BUFFER_NUM=2)DataCopy搬运,Div计算 z = x / yop_host tiling逻辑:
int64_t计算元素总数,避免溢出ACLNN验证:
aclnnDivCustomTemplate,x=1.0, y=2.0, z=0.5,test pass改动类型 / Change Type
关联 Issue / Related Issues
测试信息 / Testing
检查清单 / Checklist