Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ascend-ascendc-operator-code-gen
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/ascendc-operator-code-gen
What's inside
- Skill name
ascendc-operator-code-gen- Description
- None
- License
- MulanPSL-2.0
- Instructions
- 239 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- invalid YAML frontmatter: Nested mappings are not allowed in compact mappings at line 2, column 14:
- name: missing
- description: missing
Files (21)
- SKILL.md
- GUIDE.md · references/
- basic-data-structures-api.md · references/
- data-copy-api.md · references/
- kernel-constraints.md · references/
- resource-management-api.md · references/
- sort_topk-api.md · references/
- sync-control-api.md · references/
- vector-compute-api.md · references/
- elementwise_op_host.cpp · templates/
- elementwise_op_kernel.cpp · templates/
- index_op_host.cpp · templates/
- index_op_kernel.cpp · templates/
- index_op_per_elem_host.cpp · templates/
- index_op_per_elem_kernel.cpp · templates/
- pool_ndhwc_op_host.cpp · templates/
- pool_ndhwc_op_kernel.cpp · templates/
- row_op_host.cpp · templates/
- row_op_kernel.cpp · templates/
- sort_op_host.cpp · templates/
- sort_op_kernel.cpp · templates/
SKILL.md (first lines)
# AscendC 算子代码生成与框架适配
根据设计文档生成 op_host + op_kernel 代码,注册到 PyTorch 框架,调用 `ascendc-operator-compile-debug` skill 完成编译安装和精度测试。
**前置条件**: 设计文档 `ascend-kernel/csrc/ops/<op_name>/design.md` 已就绪,目录结构已创建。
## 工作流程总览
```
读取设计文档 → 加载 reference → 选择模板 → 生成 op_host + op_kernel
→ 框架适配 (ops.h + register.cpp + csrc/CMakeLists.txt)
→ 调用 ascendc-operator-compile-debug skill (编译 + 安装 + 测试)
```
---
## 阶段 1: 加载参考文档
**MANDATORY — READ BEFORE CODING**: 读取 [`references/GUIDE.md`](references/GUIDE.md),根据设计文档中的算子类型,加载对应的 reference 文件。**绝对不要跳过此步骤。**
## 阶段 2: 读取设计文档
从 `ascend-kernel/csrc/ops/<op_name>/design.md` 提取:
| 提取项 | 设计文档章节 | 用途 |
|--------|------------|------|
| 函数签名 + 支持的数据类型 | 原型设计 | op_host 函数原型、kernel 模板参数 |
| 算子类型 | Tiling 切分 → 步骤1 | 选择模板 (elementwise / row) |
| UB 分配表 | UB 空间分配 | 推导 bufferCoefficient、InitBuffer 大小 |
| 计算伪代码 | Kernel 实现 | Compute 函数逻辑 |
---
## 阶段 3: 选择模板并生成代码
根据算子类型选择对应模板,复制到工程目录后修改。
### 模板选择
| 算子类型 | op_host 模板 | op_kernel 模板 |
|---------|-------------|---------------|
| Elementwise (ReLU, GELU, Add...) | [`templates/elementwise_op_host.cpp`](templates/elementwise_op_host.cpp) | [`templates/elementwise_op_kernel.cpp`](templates/elementwise_op_kernel.cpp) |
| 行处理 (LayerNorm, Softmax...) | [`templates/row_op_host.cpp`](templates/row_op_host.cpp) | [`templates/row_op_kernel.cpp`](templates/row_op_kernel.cpp) |
| Index-PerRow (IndexSelect, 共享1D索引) | [`templates/index_op_host.cpp`](templates/index_op_host.cpp) | [`templates/index_op_kernel.cpp`](templates/index_op_kernel.cpp) |
| Index-PerElem (Gather, Scatter, 逐行索引) | [`templates/index_op_per_elem_host.cpp`](templates/index_op_per_elem_host.cpp) | [`templates/index_op_per_elem_kernel.cpp`](templates/index_op_per_elem_kernel.cpp) |
| Sort (Sort, TopK...) | [`templates/sort_op_host.cpp`](templates/sort_op_host.cpp) | [`templates/sort_op_kernel.cpp`](templates/sort_op_kernel.cpp) |
| Pool (MaxPool, AvgPool...) | [`templates/pool_ndhwc_op_host.cpp`](templates/pool_ndhwc_op_host.cpp) | [`templates/pool_ndhwc_op_kernel.cpp`](templates/pool_ndhwc_op_kernel.cpp) |
**MANDATORY**: 读取对应模板文件的完整内容,复制到目标路径后修改。
### 生成步骤
1. 读取选中的 op_host 和 op_kernel 模板的完整内容
2. 将内容写入 `ascend-kernel/csrc/ops/<op_name>/op_host/<op_name>.cpp` 和 `op_kernel/<op_name>.cpp`(覆盖骨架占位文件)
3. 替换所有占位符(`<op_name>`, `<OpName>` 等)
4. 根据设计文档修改:
- **op_host**: 函数签名、输入校验、`bufferCoefficient`、EXEC_KERNEL_CMD 参数
- **op_kernel**: Init 的 GM 参数、InitBuffer 大小、Compute 计算逻辑
### FP16/FP32 模板分支
Kernel 模板使用 `template <typename T>` 泛型 + `if constexpr` 分支处理不同数据类型:
```cpp
if constexpr (sizeof(T) == sizeof(float)) {
// float32 直接计算
} else {
// fp16/bf16: Cast 升精度 → fp32 计算 → Cast 降精度
}
```
AscendC 编译器支持 C++17 `if constexpr`,可安全用于模板分支。如需兼容旧编译器,也可用 `sizeof(T) == 4` 的普通 if(编译器会优化掉死分支)。
### 模板修改要点
#### 硬件参数获取(模板已内置)
模板使用平台 API 动态获取硬件参数,不再硬编码:
```cpp
#include "tiling/platform/platform_ascendc.h"
auto ascendc_platform = platform_ascendc::PlatformAscendCManager::GetInstance();
int64_t coreNum = static_cast<int64_t>(ascendc_platform->GetCoreNumAiv());
uint64_t ubSize;
ascendc_platform->GetCoreMemSize(platform_ascendc::CoreMemType::UB, ubSize);
// 需要 workspace 时:
// uint64_t sysWorkspaceSize = ascendc_platform->GetLibApiWorkSpaceSize();
```
#### bufferCoefficient 推导
从设计文档 UB 分配表推导——所有 Buffer 总大小 = `bufferCoefficient * tileLength`:
- 将 UB 分配表中所有 Buffer 的"总大小"列加和
- 结果形如 `tileLength * N`,则 `bufferCoefficient = N`
- 不同 dtype 系数不同时用 `if (dtypeSize == 2) {...} else {...}` 分支
#### FP16/BF16 升精度
**FP16 和 BF16 都必须升精度到 FP32 计算再转回**。模板中已标注升精度代码的插入位置,取消注释并填充计算逻辑即可。
#### GM ↔ UB 搬运(DataCopyPad)
**生产代码必须使用 DataCopyPad**(不要使用 DataCopy 进行 GM↔UB 搬运):
```cpp
// CopyIn: GM → UB
AscendC::DataCopyExtParams copyInParams{1,
static_cast<uint32_t>(curTileLength * sizeof(T)), 0, 0, 0};
AscendC::DataCopyPadExtParams<T> padParams{false, 0, 0, static_cast<T>(0)};
AscendC::DataCopyPad(xLocal, xGm[progress * tileLength], copyInParams, padParams);
// CopyOut: UB → GM
AscendC::DataCopyExtParams copyOutParams{1,
static_cast<uint32_t>(curTileLength * sizeof(T)), 0, 0, 0};
AscendC::DataCopyPad(yGm[progress * tileLength], yLocal, copyOutParams);
```
> **注意**: 模板文件中可能使用 DataCopy 以简化示例,生产代码应替换为 DataCopyPad。From Ascend/agent-skills, MulanPSL-2.0.
More from Ascend/agent-skills
- 0.573score
ascendc-operator-design
Ascend
完成AscendC算子设计 - 帮助用户完成算子的架构设计、接口定义和性能规划。当用户提到算子设计、算子开发、tiling策略、内存规划、AscendC kernel设计、两级tiling、核间切分、核内切分时,使用此skill。
SkillCFreshness: C★ 52Claude Code +9 - 0.573score
ascendc-operator-performance-optim
Ascend
排查并优化 Ascend C 算子性能。当用户开发、审查或优化 Ascend C kernel 算子时使用,或当用户提及 Ascend C 性能优化、算子优化、tiling、流水、搬运、 内存优化、NPU/昇腾等关键词时触发。
SkillCFreshness: C★ 52Claude Code +9 - 0.571score
ascend-transformer-boost
ascend-transformer-boost-team + Claude + Claude Code + deepseek-v4-pro
昇腾 Transformer 加速库(ATB)核心技能集索引(Index Skill)。 整合 8 大核心技能:CANN 安装部署、ATB 测试框架编译、 ATB→ACLNN 算子替换设计文档生成、ATB→ACLNN 算子迁移,覆盖昇腾 NPU 开发全链路。
SkillCFreshness: C★ 52Claude Code +9 - 0.570score
k8s-check-fix
Ascend
Kubernetes 集群健康检查与安全修复 — 诊断问题,用户确认后执行修复
SkillCFreshness: C★ 52Claude Code +9 - 0.567score
cann-nnal-installer
Ascend
昇腾NPU CANN Toolkit+Kernels+NNAL安装部署技能。支持从官网下载run包安装和从Docker镜像提取两种方式,覆盖驱动检查、包下载、安装、环境变量配置与验证全流程。当用户需要安装CANN全套组件或指定版本CANN到自定义路径时调用。
SkillCFreshness: C★ 52Claude Code +9 - 0.514score
hccl-test
Ascend
HCCL (Huawei Collective Communication Library) performance testing for Ascend NPU clusters.
SkillDFreshness: D★ 52Claude Code +9 - 0.514score
ascendc-operator-performance-eval
Ascend
在 ascend-kernel 的 csrc/ops/<op>/test 下维护仅含 JSONL 的 profiler 性能用例,使用 torch_npu.profiler(固定 warmup=5、active=5)采集,汇总 ASCEND_PROFILER_OUTPUT/op_statistic.csv 的…
SkillDFreshness: D★ 52Claude Code +9 - 0.514score
ascend-profiling-anomaly
Ascend
Analyze Huawei Ascend NPU profiling data to discover hidden performance anomalies and produce a detailed model architecture report reverse-engineered from…
SkillDFreshness: D★ 52Claude Code +9 - 0.514score
ascendc-operator-code-review
Ascend
Ascend C 代码检视技能。基于假设检验方法论对代码进行安全规范检视。调用时必须明确提供:代码片段和检视规则描述。TRIGGER when: 用户要求代码检视、代码review、询问代码安全问题、检查编码规范、或需要检查特定代码问题(如内存泄漏、整数溢出、空指针等)。关键词:Ascend…
SkillDFreshness: D★ 52Claude Code +9 - 0.514score
megatron-migration-generator
Ascend
Generate migration deliverables for bringing relevant Megatron changes into MindSpeed after branch alignment and impact mapping are complete.
SkillDFreshness: D★ 52Claude Code +9 - 0.514score
ascend-docker
Ascend
Create Docker containers for Huawei Ascend NPU development with proper device mappings and volume mounts.
SkillDFreshness: D★ 52Claude Code +9 - 0.511score
ascendc-operator-precision-debug
Ascend
AscendC 算子精度问题调试与根因定位。当算子精度测试失败(allclose 不通过、结果偏差、输出全零/NaN 等)时使用。流程:误差分布分析 → 代码易错点审查 → 实验隔离 → printf/DumpTensor 插桩 → 修复验证。关键词:精度调试、精度问题、结果不一致、误差定位、allclose…
SkillDFreshness: D★ 52Claude Code +9
Signals
- Stars
- 52
- Forks
- 3
- Open issues
- 2
- Last commit (this folder)
- May 6, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MulanPSL-2.0
- Repository
- github.com/Ascend/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Ascend
- 0.573score
ascendc-operator-design
Ascend
完成AscendC算子设计 - 帮助用户完成算子的架构设计、接口定义和性能规划。当用户提到算子设计、算子开发、tiling策略、内存规划、AscendC kernel设计、两级tiling、核间切分、核内切分时,使用此skill。
SkillCFreshness: C★ 52Claude Code +9 - 0.573score
ascendc-operator-performance-optim
Ascend
排查并优化 Ascend C 算子性能。当用户开发、审查或优化 Ascend C kernel 算子时使用,或当用户提及 Ascend C 性能优化、算子优化、tiling、流水、搬运、 内存优化、NPU/昇腾等关键词时触发。
SkillCFreshness: C★ 52Claude Code +9 - 0.570score
k8s-check-fix
Ascend
Kubernetes 集群健康检查与安全修复 — 诊断问题,用户确认后执行修复
SkillCFreshness: C★ 52Claude Code +9 - 0.567score
cann-nnal-installer
Ascend
昇腾NPU CANN Toolkit+Kernels+NNAL安装部署技能。支持从官网下载run包安装和从Docker镜像提取两种方式,覆盖驱动检查、包下载、安装、环境变量配置与验证全流程。当用户需要安装CANN全套组件或指定版本CANN到自定义路径时调用。
SkillCFreshness: C★ 52Claude Code +9 - 0.514score
ascend-profiling-anomaly
Ascend
Analyze Huawei Ascend NPU profiling data to discover hidden performance anomalies and produce a detailed model architecture report reverse-engineered from…
SkillDFreshness: D★ 52Claude Code +9 - 0.514score
ascendc-operator-code-review
Ascend
Ascend C 代码检视技能。基于假设检验方法论对代码进行安全规范检视。调用时必须明确提供:代码片段和检视规则描述。TRIGGER when: 用户要求代码检视、代码review、询问代码安全问题、检查编码规范、或需要检查特定代码问题(如内存泄漏、整数溢出、空指针等)。关键词:Ascend…
SkillDFreshness: D★ 52Claude Code +9
Cite this page
ascendc-operator-code-gen skill. Agent Mart. https://agentmart.dev/skills/ascend-ascendc-operator-code-gen (last updated 2026-10-24)