Creates Ascend C Kernel direct-invoke projects with verified Vector (add_custom), Blaze Matmul (pure/fused/MX quant/GroupMatmul), and Kirin Vector templates. Use for kernel prototyping, Ascend C learning, or matmul template needs.
Ships in ops-direct-invoke-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
先按算子类型路由到模板,再按 [MODIFY] 注释改造。
| 算子类型 | 入口 | 典型算子 |
|---|---|---|
| Vector | references/add_custom/ | add、mul、relu、softmax、layernorm 等逐元素/归约算子 |
| Blaze Matmul(A5/DAV_3510) | references/matmul_blaze_template/ + references/matmul_blaze_guide.md | MatMul、BatchMatMul、matmul+bias、mxfp8 matmul、matmul+vector 融合、GroupMatmul |
| Kirin Vector(端侧开发) | references/kirin_add_template/ + references/kirin_vector_guide.md | Kirin SoC(KirinX90/Kirin9030)专用逐元素/归约算子 |
# 若算子目录 <your_op> 未创建
cp -r references/add_custom <your_op>
# 若算子目录 <your_op> 已存在
cp -r references/add_custom/* <your_op>
cd <your_op>
add_custom → <your_op>(add_custom 是整体算子名,_kernel/_torch/_tiling 是固定后缀)[MODIFY] 标记改造:
add_custom_tiling.h)add_custom_kernel.asc)CMakeLists.txt 中的目标名# 完整流程(含编译)
bash run.sh
# 仅运行测试,复用已有编译产物
bash run.sh --skip-build
run.sh在运行 kernel 前会自动删除旧的output/output.bin,确保精度验证读取的是本次运行的新鲜输出。
见 references/matmul_blaze_guide.md(独立自洽):按场景路由选择模板,复制 matmul_blaze_template/ 工程后按指南改造。
见 references/kirin_vector_guide.md(独立自洽):复制 references/kirin_add_template/ 工程后按 guide 进行修改。
├── op_kernel/ NPU 计算层
│ ├── add_custom_tiling.h Tiling 常量 + 结构体(kernel 和 host 共用)
│ └── add_custom_kernel.asc 纯 kernel 代码(KernelAdd 类 + add_custom_kernel 核函数入口)
├── op_host/ Host 直调层
│ ├── add_custom.asc Host + main 入口(#include "add_custom_kernel.asc")
│ └── data_utils.h 数据读写工具
├── op_extension/ PyTorch 接入层
│ ├── add_custom_torch.cpp PyTorch host 实现(Tiling 计算 + kernel launch)
│ ├── register.cpp TORCH_LIBRARY 注册(含 Meta backend)
│ └── ops.h 函数声明
├── scripts/ 测试脚本
│ ├── gen_data.py 生成输入数据
│ ├── golden.py Golden 计算函数(直调 & PyTorch 双通路共用)
│ ├── verify_result.py 直调通路精度验证
│ └── test_torch.py PyTorch 通路测试
├── CMakeLists.txt 双 target:可执行文件 + libadd_custom_ops.so
├── run.sh 一键运行(支持 --torch 跑 PyTorch 通路)
└── README.md
在 add_custom_kernel.asc 和 add_custom.asc 中可直接学习:
TPipe + TQue 管理 UB BufferEnQue/DeQue 确保操作顺序模板已内置 PyTorch 对接,编译后即可使用:
import torch; import torch_npu
torch.ops.load_library("build/libadd_custom_ops.so")
y = torch.ops.npu.add_custom(x1, x2)
| 文件 | 说明 |
|---|---|
references/matmul_blaze_guide.md | Blaze Matmul 工程模板指南(架构 + 场景路由 + 使用指南) |
references/kernel_launch_details.md | 进阶(通用):内存层次/Double Buffer/同步机制/多 I/O |
npu-arch skilltorch-ascendc-op-extension skillevals/evals.json (opens in a new tab)references/add_custom/CMakeLists.txt (opens in a new tab)references/add_custom/README.md (opens in a new tab)references/add_custom/op_extension/add_custom_torch.cpp (opens in a new tab)references/add_custom/op_extension/ops.h (opens in a new tab)references/add_custom/op_extension/register.cpp (opens in a new tab)references/add_custom/op_host/add_custom.asc (opens in a new tab)references/add_custom/op_host/data_utils.h (opens in a new tab)references/add_custom/op_kernel/add_custom_kernel.asc (opens in a new tab)references/add_custom/op_kernel/add_custom_tiling.h (opens in a new tab)references/add_custom/run.sh (opens in a new tab)references/add_custom/scripts/gen_data.py (opens in a new tab)references/add_custom/scripts/golden.py (opens in a new tab)references/add_custom/scripts/test_torch.py (opens in a new tab)references/add_custom/scripts/verify_result.py (opens in a new tab)references/kernel_launch_details.md (opens in a new tab)references/kirin_add_template/CMakeLists.txt (opens in a new tab)references/kirin_add_template/README.md (opens in a new tab)references/kirin_add_template/UPSTREAM.md (opens in a new tab)references/kirin_add_template/add_custom.cpp (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/ops-direct-invoke-skills:ascendc-direct-invoke-templatefrom ops-direct-invoke-skills
npx claudepluginhub hicann/cannbot-skills --plugin ops-direct-invoke-skills25 skills in this plugin
/ascendc-api-best-practicesAscend C API 使用最佳实践。提供算术、归约、数据搬运、Buffer管理、精度转换、通信接口等 API 的正确用法和限制说明。触发:用户询问具体 API 用法(如"DataCopy 怎么用"、"ReadNbi 怎么用")、遇到 API 参数错误或限制报错(如 repeatTimes、对齐问题)、需要查看 API 最佳实践或避坑指南、算子性能疑似受标量访问/单元素读写影响时。/ascendc-blaze-best-practice在 Ascend 950 / DAV_3510 平台上,基于 Blaze/tensor_api 开发 Basic、Batch、Grouped、Quantized、MX 等 MatMul 类算子或相关的融合算子时使用。不适用于纯 Vector 算子或 A2/A3 平台。/ascendc-blaze-migration评估并将 ops-nn、ops-transformer 等仓中 Ascend 950 / DAV_3510 的 AscendC Kernel 分支等价迁移到 ops-tensor Blaze/Tensor API。适用于 CMCT、CGMCT、单体或自定义分层 Kernel,以及 Cube、Vector、MIX、高阶 Matmul、手工 Buffer、数据搬运、自定义调度、VF 和同步路径;在隔离迁移工程中串行完成迁移合同冻结、Blaze 开发、验证资产生成、原始基线、Blaze 验收和双仓本地提交交付。/ascendc-code-reviewAscend C 代码检视技能。触发:检视代码、检视 PR、检查是否有问题、快速检视。支持文件检视、PR 检视、快速定向检视、设计一致性检查。自动识别代码侧别、提取适用条例、执行假设检验驱动的逐条检视。/ascendc-crash-debugAscend C 算子卡死/崩溃/内存错误调试路由技能。用于处理程序无法运行完或执行异常崩溃的场景:(1) 程序卡死/挂起/超时,Kernel 无响应,(2) 程序崩溃(Segmentation Fault、Abort),(3) Buffer 冲突/死锁导致的核心挂起,(4) 需要解析 plog 日志定位卡死/崩溃位置,(5) 偶发崩溃/结果异常(怀疑内存越界踩踏),需要主动检测内存错误。触发关键词:卡死、挂起、超时、崩溃、hang、crash、deadlock、Segmentation Fault、Abort、Kernel hang、内存越界、plog、memcheck、内存检查、内存错误、偶发崩溃、aic error、非法读写。/ascendc-docs-genAscend C 算子文档生成与写作参考。触发:用户要求结合算子规格、需求、设计文档和源码生成或更新 aclnn 接口文档、算子 README(含基于同算子不同版本对比的增量更新),或生成需求分析、详细设计、迭代计划等标准文档。2 plugins ship this exact skill · first indexed Oct 20, 2026
Other plugins' skills for the same job