external-gitcode-ascend-atb-aclnn-operator-migration

Automatically perform migration of ATB operators to ACLNN to enable ACLNN acceleration on 910B/950 devices. Supports parameter mapping and ACLNN Runner.

Last repository push
GitHub Stars
187
Forks
67
Issues / PRs
15

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "external-gitcode-ascend-atb-aclnn-operator-migration" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-89858721c0ed5052e19f8f2d0bcd5b6d0692878e3d70e74bb5d96d792c6a9cee. Verify the upstream source and version against https://github.com/ascend-ai-coding/awesome-ascend-skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Automatically perform migration of ATB operators to ACLNN to enable ACLNN acceleration on 910B/950 devices. Supports parameter mapping and ACLNN Runner.

0 Downloads

Introduction source: third_party · ascend-ai-coding · 1.2.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: external-gitcode-ascend-atb-aclnn-operator-migration
description: '自动执行 ATB 算子到 ACLNN 的迁移操作,在 910B/950 设备上启用 ACLNN 加速。 支持参数映射、ACLNN Runner
  实现、设备检测切换和功能/性能验证全流程。

  '
keywords:
- atb
- aclnn
- migration
- operator
- 昇腾
- ascend
- 910b
- 950
metadata:
  author: ascend-transformer-boost-team + Claude Code + opus4.7
  version: 1.2.0
  created: '2026-04-17'
  updated: '2026-04-28'
  skill-type: migration
hooks:
  PreToolUse:
  - matcher: Write|Edit|Bash
    hooks:
    - type: command
      command: ([ -z "$CANN_PATH" ] || [ ! -f "$CANN_PATH/set_env.sh" ]) && echo '[PATH
        CHECK] CANN_PATH 未设置或无效,请先向用户获取 CANN 路径' >&2; ([ -z "$ATB_REPO_PATH" ] ||
        [ ! -d "$ATB_REPO_PATH" ]) && echo '[PATH CHECK] ATB_REPO_PATH 未设置或无效,请先向用户获取
        ATB 路径' >&2 || true
original-name: atb-aclnn-operator-migration
synced-from: https://gitcode.com/Ascend/agent-skills
synced-date: '2026-05-26'
synced-commit: 1f7666e7768a0ceb21bb1d40ce4b5179fcb6f1d6
license: UNKNOWN

ATB到ACLNN算子迁移工具

功能概述

该工具帮助开发者将ATB中的算子迁移到ACLNN实现,特别是在 910B/950 设备上获得更好的兼容性优化。

调用时机

在以下情况下调用此技能:

  • 用户需要将 ATB 算子迁移到 ACLNN 实现以提升 910B/950 设备性能
  • 用户已生成算子替换设计文档(建议先运行 atb-aclnn-operator-replacement-designer)
  • 用户需要在 ATB 源码上应用 ACLNN Runner 改造

⚠️ 路径约束(必须执行)

执行此技能前,必须从用户处获取以下路径:

  • <CANN_PATH>: CANN 安装路径(如 /usr/local/Ascend/ascend-toolkit/latest)
  • <ATB_REPO_PATH>: ATB 仓库路径(如 {your working path}ascend-transformer-boost)

若用户未提供或路径无效,立即停止并报错。


前置条件

  • CANN 环境已安装(ASCEND_TOOLKIT_HOME 已设置)
  • ATB 源码仓库已克隆至本地
  • 算子对应的 ATB 接口文档和 ACLNN 接口文档已获取
  • 建议已完成 atb-aclnn-operator-replacement-designer 生成设计文档

<details> <summary>检查点系统(点击展开)</summary>

每个操作步骤末尾的 检查点 标记了验证标准。执行完成后请在 执行结果 章节填写实际状态。

检查点 ID 描述 验证命令
Step0-ENV CANN 环境 sourced echo $ASCEND_TOOLKIT_HOME
Step0-DIR ATB 源码目录存在 [ -d <ATB_REPO_PATH> ]
Step1-DIR 原有 Operation 源文件定位 ls <op>_operation.cpp
Step1-DIR 现有 ACLNN runner 参考定位 ls softmax_aclnn_runner.cpp
Step2-FILE <op>_aclnn_runner.h 创建 [ -f <op>_aclnn_runner.h ]
Step2-FILE <op>_aclnn_runner.cpp 创建 [ -f <op>_aclnn_runner.cpp ]
Step2-CODE BuildAclnnVariantPack 实现 grep "BuildAclnnVariantPack" <op>_aclnn_runner.cpp
Step2-CODE SetAclNNWorkspaceExecutor 实现 grep "SetAclNNWorkspaceExecutor" <op>_aclnn_runner.cpp
Step2-CODE LaunchAclnnKernel 实现 grep "LaunchAclnnKernel" <op>_aclnn_runner.cpp
Step2-CODE LoadMethod 实现 grep "LoadMethod" <op>_aclnn_runner.cpp
Step3-MOD CreateRunner 包含 910B/950 分支 grep "Is910B\|Is950\|910B\|950" <op>_operation.cpp
Step4-BUILD 编译成功无错误 make ... 2>&1
Step5-TEST 非 910B/950 设备功能正常 ./apitest ...

</details>

迁移步骤

步骤1: 分析ATB算子实现

  1. 理解ATB算子参数结构

    • 查看 infer_op_params.h 中的参数结构
    • 确认参数类型和约束
  2. 分析现有实现

    • 查看 <operator>_operation.cpp 了解操作逻辑
    • 分析 <operator>_ops_runner.cpp 了解现有runner实现
  3. 研究ACLNN接口

    • 了解对应ACLNN算子的接口
    • 分析参数映射关系

步骤2: 创建ACLNN Runner

  1. 创建头文件 (<operator>_aclnn_runner.h)

    • 继承自 AclnnRunner 基类
    • 定义必要的成员变量和方法
    • 声明ACLNN函数指针
  2. 实现源文件 (<operator>_aclnn_runner.cpp)

    • 实现 BuildAclnnVariantPack 方法处理张量转换
    • 实现 SetAclNNWorkspaceExecutor 方法配置工作空间
    • 实现 LaunchAclnnKernel 方法执行计算
    • 实现 LoadMethod 方法动态加载ACLNN函数

步骤3: 修改Operation实现

  1. 更新头文件包含

    • 添加 #include "<operator>_aclnn_runner.h"
  2. 修改CreateRunner方法

    • 添加设备检测逻辑
    • 在910B/950设备上使用 <Operator>AclnnRunner
    • 在其他设备上保持原有 <Operator>OpsRunner
  3. 更新设备支持

    • 修改 CreateOperation 函数
    • 支持910B/950训练设备
    • 保持对其他设备的支持

步骤4: 构建和验证

  1. 编译验证

    • 确保代码通过编译
    • 检查是否有编译错误或警告
  2. 功能验证

    • 在910B/950设备上验证ACLNN实现
    • 在其他设备上验证原有实现
    • 确保功能正确性
  3. 性能验证

    • 对比ATB和ACLNN实现的性能
    • 确保在910B/950设备上获得性能提升

<details> <summary>技术要点(点击展开)</summary>

核心实现

  1. 参数映射

    • ATB参数到ACLNN参数的映射
    • 处理输入输出张量的转换
  2. 设备检测

    • 使用 GetSingleton<Config>().Is910B() 检测 910B 设备类型
    • 使用 GetSingleton<Config>().Is950() 检测 950 设备类型
    • 根据设备类型选择合适的 runner
  3. 内存管理

    • 自动管理ACLNN工作空间
    • 合理处理张量数据指针
  4. 错误处理

    • 完善的日志记录
    • 错误码处理和返回

性能优化

  1. ACLNN加速

    • 利用ACLNN的硬件优化
    • 减少内存访问开销
  2. 条件编译

    • 根据设备类型选择最优实现
    • 保持代码兼容性

注意事项

  1. 设备兼容性

    • 确保在不同设备上的正确运行
    • 处理设备特定的参数和约束
  2. 接口一致性

    • 保持原有ATB接口不变
    • 确保上层应用无需修改
  3. 测试覆盖

    • 编写针对不同设备的测试用例
    • 验证性能和功能正确性
  4. 错误处理

    • 完善的错误处理机制
    • 详细的日志记录 </details>

示例使用

步骤1: 准备环境

# 确保CANN环境正确配置
# 确保ATB代码库已更新

步骤2: 应用迁移

# 在ATB代码库中应用迁移
git apply <operator>_aclnn_migration.patch

步骤3: 编译验证

# 编译ATB代码
cd ascend-transformer-boost
mkdir build && cd build
cmake ..
make -j

步骤4: 功能测试

# 运行算子测试
./tests/apitest/opstest/python/operations/<operator>/test_<operator>.py

步骤5: 性能测试

# 对比ATB和ACLNN实现的性能
python performance_benchmark.py

<details> <summary>常见问题(点击展开)</summary>

Q: 编译失败怎么办?

A: 检查CANN版本是否兼容,确保ACLNN接口可用。

Q: 910B/950设备上性能没有提升?

A: 检查ACLNN函数是否正确加载,验证工作空间配置。

Q: 其他设备上功能异常?

A: 确保设备检测逻辑正确,验证原有实现未受影响。 </details>

总结

通过该工具,开发者可以轻松将ATB算子迁移到ACLNN实现,在910B/950设备上获得更好的性能,同时保持对其他设备的兼容性。该实现遵循项目代码规范,与现有ACLNN runner实现保持一致,确保代码质量和可维护性。

执行结果

⚠️ 执行后填写:技能执行完成后,参照下方格式填写实际执行结果。

检查点检查表

步骤 检查点描述 状态
1 ATB 源码目录存在 ✅ PASS / ❌ FAIL / ⏭️ SKIP
1 原有 Operation 源文件定位 ✅ PASS / ❌ FAIL / ⏭️ SKIP
1 现有 ACLNN runner 参考定位 ✅ PASS / ❌ FAIL / ⏭️ SKIP
2 <op>_aclnn_runner.h 创建 ✅ PASS / ❌ FAIL / ⏭️ SKIP
2 <op>_aclnn_runner.cpp 创建 ✅ PASS / ❌ FAIL / ⏭️ SKIP
2 BuildAclnnVariantPack 实现 ✅ PASS / ❌ FAIL / ⏭️ SKIP
2 SetAclNNWorkspaceExecutor 实现 ✅ PASS / ❌ FAIL / ⏭️ SKIP
2 LaunchAclnnKernel 实现 ✅ PASS / ❌ FAIL / ⏭️ SKIP
2 LoadMethod 实现 ✅ PASS / ❌ FAIL / ⏭️ SKIP
3 CreateRunner 包含 910B/950 分支 ✅ PASS / ❌ FAIL / ⏭️ SKIP
4 编译成功 ✅ PASS / ❌ FAIL / ⏭️ SKIP
5 非 910B/950 设备功能正常 ✅ PASS / ❌ FAIL / ⏭️ SKIP
5 910B 设备 ACLNN 路径正常 ✅ PASS / ❌ FAIL / ⏭️ SKIP
5 950 设备 ACLNN 路径正常 ✅ PASS / ❌ FAIL / ⏭️ SKIP

VERDICT: ✅ SUCCESS / ⚠️ PARTIAL / ❌ FAILED / ⏭️ SKIPPED

问题列表(若有)

等级 检查点 问题描述 建议
🔴 CRITICAL - - -
🟡 WARNING - - -

执行摘要

  • 执行时间:
  • 执行环境:
  • 算子名称:
  • 持续时间:
  • 通过率:

Current listing version

1.2.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供完整的ATB到ACLNN算子迁移解决方案
  • 支持910B/950设备检测和性能优化
  • 包含参数映射、ACLNN Runner实现等全流程
Trigger Precision85/100

Highlights

  • description完整描述技能用途和适用场景
  • 关键词覆盖合理,包含昇腾生态相关术语
  • 调用时机说明清晰,前置条件明确
Structure and Standards75/100

Areas to improve

  • 文档过长 Reported severity: Minor

    SKILL.md文件约600行,超过500行建议长度

    Recommendation: 考虑将部分内容移至单独文档或使用更简洁的表达方式

  • frontmatter license字段 Reported severity: Minor

    license字段值为UNKNOWN,建议填写具体许可证类型

    Recommendation: 根据昇腾生态规范填写正确的许可证类型

Highlights

  • Phase/步骤清晰,分为4个主要步骤
  • 有出口条件(检查点系统)便于验证
  • 含端到端示例和常见问题解答
Execution Reliability80/100

Highlights

  • 工具来源明确(昇腾生态ATB项目)
  • 参数正确(CANN_PATH, ATB_REPO_PATH)
  • 覆盖主要异常(路径检查、设备检测)
  • 不可逆操作有确认机制(前置条件检查)
Evidence Verifiability (mean of the first four)79/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • gitcode.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.