Initializes AscendC operator projects with compilable skeletons. Detects existing ascend-kernel projects, creates csrc/ops/ structure, and outputs a checklist for further development.
Ships in external-gitcode-ascend-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; scripts run unread.
Skill类型:流程导向型(多阶段工作流,阶段检查点)
快速创建 Ascend-Kernel 算子工程,所有算子统一生成在 csrc/ops 目录下,并保证后续可直接进入设计/编码/编译测试阶段。
csrc/ops 目录下EXEC_KERNEL_CMD 左值要求、环境依赖digraph project_init {
rankdir=TB;
node [shape=box];
start [label="用户请求创建算子" shape=ellipse];
detect_ascend_kernel [label="检测ascend-kernel项目是否存在" shape=diamond];
detect_ops [label="检测csrc/ops/目录是否存在" shape=diamond];
copy_template [label="复制ascend-kernel项目模板到当前目录"];
create_ops_dir [label="创建csrc/ops目录"];
collect [label="收集算子信息"];
check_path [label="检查目标算子路径是否存在" shape=diamond];
show_exists [label="提示路径已存在,询问是否更换"];
show_result [label="展示目录结构和下一步指引"];
start -> detect_ascend_kernel;
detect_ascend_kernel -> detect_ops [label="存在"];
detect_ascend_kernel -> copy_template [label="不存在"];
copy_template -> collect;
detect_ops -> collect [label="存在ops/"];
detect_ops -> create_ops_dir [label="不存在ops/"];
create_ops_dir -> collect;
collect -> check_path;
check_path -> show_exists [label="存在"];
show_exists -> collect [label="更换名称"];
check_path -> show_result [label="不存在"];
}
op_host/ 和 op_kernel/ops.h、register.cpp、csrc/CMakeLists.txt(三处)EXEC_KERNEL_CMD 中直接传右值临时变量检测策略:
执行命令:
bash <skill_dir>/scripts/detect_ascend_kernel_project.sh
| 检测结果 | 处理方式 |
|---|---|
PROJECT_FOUND:<path> | 使用现有项目,继续步骤2 |
PROJECT_FOUND_NO_OPS:<path> | 在项目中创建csrc/ops/目录,继续步骤2 |
PROJECT_NOT_FOUND | 复制ascend-kernel模板到当前目录,继续步骤2 |
MULTIPLE_PROJECTS:<path1> <path2> ... | 列出所有项目,让用户选择 |
执行命令:
cp -r "<skill_dir>/templates/ascend-kernel" ./ascend-kernel
chmod +x ./ascend-kernel/build.sh
重要:复制后必须 chmod +x build.sh,否则编译时会报 Permission denied。
验证:确认ascend-kernel目录包含:
必须确认的信息:
| 信息 | 格式要求 | 说明 |
|---|---|---|
| 算子名称 | snake_case | 如 rms_norm, flash_attn |
确认信息:
=== Ascend-Kernel算子信息 ===
算子名称: <op_name>
生成路径: <ascend_kernel_path>/csrc/ops/<op_name>
确认创建?[Y/n]
mkdir -p csrc/ops)csrc/ops/<op_name> 不存在创建目录:
mkdir -p csrc/ops/<op_name>/op_host csrc/ops/<op_name>/op_kernel
在 csrc/ops/<op_name>/ 下创建以下文件:
csrc/ops/<op_name>/
├── CMakeLists.txt
├── design.md # 设计文档占位(由 design skill 填充)
├── op_host/
│ └── <op_name>.cpp # Host 占位(由 code-gen skill 替换)
└── op_kernel/
└── <op_name>.cpp # Kernel 占位(由 code-gen skill 替换)
CMakeLists.txtascendc_add_operator(OP_NAME <op_name>)
op_host/<op_name>.cpptorch_kernel_helper.haclrtlaunch_<op_name>.hnamespace ascend_kernel { at::Tensor <op_name>(...) { ... } } 占位op_kernel/<op_name>.cppkernel_operator.hextern "C" __global__ __aicore__ void <op_name>(...) 占位初始化完成后,明确提示用户/后续 skill 更新以下三处:
csrc/ops.h:添加函数声明csrc/register.cpp:添加 m.def 与 m.implcsrc/CMakeLists.txt:
OP_SRCS 添加 host 文件ascendc_library(...) 添加 kernel 文件aclnn/<op>.cpp说明:这是实战最高频遗漏点,必须在初始化阶段提前提示。
提示用户:
Ascend-Kernel项目初始化成功!
项目结构:
<ascend_kernel_path>/
├── build.sh # 构建脚本
├── CMakeLists.txt # CMake配置
├── csrc/
│ ├── ops/ # 算子目录
│ ├── aclnn/ # ACLNN算子封装
│ ├── utils/ # 工具类
│ ├── ops.h # 算子声明
│ └── register.cpp # 算子注册
├── python/ # Python包
└── tests/ # 测试用例
下一步操作:
调用 ascendc-operator-design skill 完成设计文档
EXEC_KERNEL_CMD 参数必须是左值;如 double 先转 float 局部变量再传完成本 skill 后,至少应满足:
ascend-kernel 项目csrc/ops/<op_name>/ 标准骨架ops.h / register.cpp / csrc/CMakeLists.txt)scripts/detect_ascend_kernel_project.sh (opens in a new tab)templates/ascend-kernel/CMakeLists.txt (opens in a new tab)templates/ascend-kernel/build.sh (opens in a new tab)templates/ascend-kernel/cmake/config_ascend.cmake (opens in a new tab)templates/ascend-kernel/cmake/config_envs.cmake (opens in a new tab)templates/ascend-kernel/cmake/config_git_last_commit.cmake (opens in a new tab)templates/ascend-kernel/config.ini (opens in a new tab)templates/ascend-kernel/csrc/CMakeLists.txt (opens in a new tab)templates/ascend-kernel/csrc/aclnn/avg_pool3d.cpp (opens in a new tab)templates/ascend-kernel/csrc/ops.h (opens in a new tab)templates/ascend-kernel/csrc/ops/helloworld/op_host/helloworld.cpp (opens in a new tab)templates/ascend-kernel/csrc/ops/helloworld/op_kernel/kernel_helloworld.cpp (opens in a new tab)templates/ascend-kernel/csrc/register.cpp (opens in a new tab)templates/ascend-kernel/csrc/utils/torch_aclnn_helper.h (opens in a new tab)templates/ascend-kernel/csrc/utils/torch_kernel_helper.h (opens in a new tab)templates/ascend-kernel/python/ascend_kernel/ascend_kernel/__init__.py (opens in a new tab)templates/ascend-kernel/python/ascend_kernel/setup.py (opens in a new tab)templates/ascend-kernel/tests/test_avg_pool3d.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
/external-gitcode-ascend-skills:external-gitcode-ascend-ascendc-operator-project-initfrom external-gitcode-ascend-skills
npx claudepluginhub ascend-ai-coding/awesome-ascend-skills --plugin external-gitcode-ascend-skills91 skills in this plugin
/external-gitcode-ascend-analyse-coverage分析测试覆盖率盲区,生成覆盖率分析报告/external-gitcode-ascend-arxiv-recommendation-npu自动化推荐系统论文发现流水线。抓取 arxiv 推荐论文,检测源码,生成待迁移任务清单,由 npu-model-migration skill 完成 NPU 适配。/external-gitcode-ascend-ascendc-operator-code-gen根据设计文档生成 AscendC 算子完整代码实现并完成框架适配。TRIGGER when: 设计文档已完成,需要生成 op_host/op_kernel 代码、注册到 PyTorch 框架、编译测试。关键词:代码生成、op_host、op_kernel、tiling、kernel、框架适配、算子注册。Other plugins' skills for the same job