Atb Csv Testcase Generator logo

Atb Csv Testcase Generator

Organization
Ascend
atb-csv-testcase-generator

ATB CSV 测试用例生成技能。当用户需要为 ATB 算子创建 CSV 格式的泛化测试用例时调用此技能。 覆盖:正例设计、反例设计、性能测试用例、CSV 格式规范。

Overview

PublisherAscend
Repositoryagent-skills
Skill nameatb-csv-testcase-generator
Stars
54
Forks
4
Bundled files
Instructions only
LicenseMulanPSL-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Ascend on GitHub. Read the source before you install it.

Installation

Install the Atb Csv Testcase Generator AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Ascend/agent-skills/tree/master/skills/ascend-transformer-boost/skills/atb-csv-testcase-generator
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Ascend/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/ascend-transformer-boost/skills/atb-csv-testcase-generator .claude/skills/atb-csv-testcase-generator
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Atb Csv Testcase Generator in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Atb Csv Testcase Generator on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Atb Csv Testcase Generator is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

ATB CSV Testcase Generator

功能概述

此技能用于为 ATB 算子生成 CSV 格式的泛化测试用例,支持正例、反例和性能测试用例设计。

调用时机

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

  • 用户需要为 ATB 算子创建 CSV 测试用例
  • 用户需要生成正例、反例或性能测试用例

任务分块

类型说明数量建议
正例验证正常功能,覆盖典型场景5-15 个
反例覆盖所有参数校验分支10-20 个
性能测试大小 shape 性能验证5-10 个

任务前提知识

  1. 参考已有 CSV 文件:tests/apitest/opstest/csv/ 目录下有丰富的参考用例
  2. 性能测试标记:TestType 列填写 Performance 即为性能测试
  3. 预期错误标记:ExpectedError 列填写错误类型,如 NO_ERROR、I:ERROR_INVALID_TENSOR_DIM 等

数据类型覆盖

  • float16 (最常用)
  • bf16 (高精度场景)

Shape 典型性

包含主流模型的常见 shape:

  • Llama: 512, 7168 (hidden_size=3584)
  • GPT: 256, 12288 (hidden_size=6144)
  • Mini batch: 1-16 tokens
  • Large batch: 1024-2048 tokens

边界条件

  • UB 上限边界(如 hidden_size=31424)
  • 非对齐 hidden_size(如 130, 65)
  • 最小 shape(如 1, 64)

正例模板

csv
CaseNum|CaseName|OpName|OpParam|InNum|InDType|InFormat|InShape|OutNum|OutDType|OutFormat|OutShape|DataGenType|DataGenRange|InTensorFile|OutTensorFile|TestType|TestLevel|FromModel|SocVersion|ExpectedError
1      |XxxBase |XxxOperation|{"param":0}|1|float16|nd|128,4096|2|int8;float|nd;nd|128,2048;128|customize|-100,100;|||||||Ascend910B;Ascend950|NO_ERROR

数据类型错误

csv
# 只支持 float16/bf16,不支持 int64
SwigluQuantErrorDtypeInt64|SwigluQuantOperation|{"quantType":0}|1|int64|nd|128,4096|...|I:ERROR_INVALID_TENSOR_INI_MATCH

维度错误

csv
# dimNum 必须为 2
SwigluQuantErrorDimNum|SwigluQuantOperation|{"quantType":0}|1|float16|nd|128,4096,1|...|I:ERROR_INVALID_TENSOR_DIM_NUM

维度值错误

csv
# hidden_size 必须能被 2 整除
SwigluQuantErrorHiddenSizeOdd|SwigluQuantOperation|{"quantType":0}|1|float16|nd|128,4097|...|I:ERROR_INVALID_TENSOR_DIM

参数错误

csv
# quantType 只能为 0
SwigluQuantErrorParam|SwigluQuantOperation|{"quantType":1}|1|float16|nd|128,4096|...|C:ERROR_INVALID_PARAM

Shape 边界超限

csv
# UB 上限检查
SwigluQuantErrorHiddenSizeTooLarge|SwigluQuantOperation|{"quantType":0}|1|float16|nd|5,15714|...|I:ERROR_INVALID_TENSOR_DIM

反例覆盖检查表

校验类型ExpectedError覆盖场景
数据类型I:ERROR_INVALID_TENSOR_INI_MATCHint64, int32, float32, bool
数据格式I:ERROR_INVALID_TENSOR_INI_MATCHfractal_z, ncdhw 等
维度数量I:ERROR_INVALID_TENSOR_DIM_NUM1D, 3D, 4D
维度值I:ERROR_INVALID_TENSOR_DIM0, 奇数, 超限
参数校验C:ERROR_INVALID_PARAM非法参数值
输出 ShapeS:ERROR_INVALID_TENSOR_DIMshape 不匹配
UB 边界I:ERROR_INVALID_TENSOR_DIMhidden_size 过大

大小 Shape 覆盖

csv
# 大 shape
SwigluQuantPerformanceLarge|SwigluQuantOperation|{"quantType":0}|1|float16|nd|2048,16384|...|Performance|Ascend910B;Ascend950|NO_ERROR

# 中 shape
SwigluQuantPerformanceMedium|SwigluQuantOperation|{"quantType":0}|1|float16|nd|512,8192|...|Performance|Ascend910B;Ascend950|NO_ERROR

# 小 shape
SwigluQuantPerformanceSmall|SwigluQuantOperation|{"quantType":0}|1|float16|nd|64,256|...|Performance|Ascend910B;Ascend950|NO_ERROR

不同数据类型

csv
# bf16 性能
SwigluQuantPerformanceBf16|SwigluQuantOperation|{"quantType":0}|1|bf16|nd|1024,8192|...|Performance|Ascend910B;Ascend950|NO_ERROR

边界值测试

csv
# hidden_size 边界
SwigluQuantPerformanceHidden4096|SwigluQuantOperation|{"quantType":0}|1|float16|nd|256,8192|...|Performance|Ascend910B;Ascend950|NO_ERROR

列说明

列号名称说明
1CaseNum用例编号
2CaseName用例名称
3OpName算子名称(如 SwigluQuantOperation)
4OpParamJSON 格式参数字符串
5InNum输入张量数量
6InDType输入数据类型(分号分隔)
7InFormat输入数据格式(分号分隔)
8InShape输入形状(分号分隔)
9OutNum输出张量数量
10OutDType输出数据类型
11OutFormat输出数据格式
12OutShape输出形状
13DataGenType数据生成类型(通常为 customize)
14DataGenRange数据生成范围
15InTensorFile输入张量文件(空)
16OutTensorFile输出张量文件(空)
17TestType测试类型(空或 Performance)
18TestLevel测试级别(空)
19FromModel来源模型(空)
20SocVersion目标 SoC(如 Ascend910B、Ascend950。多个设备用 ; 分隔:Ascend910B;Ascend950)
21ExpectedError期望错误(NO_ERROR 或错误类型)

数据类型映射

在 CSV 中使用 data_generation.py 支持的数据类型名称:

实际类型CSV 中使用
float32float
float16float16 或 half
bfloat16bf16 或 bfloat16
int8int8 或 char
int32int32 或 int
int64int64 或 long

常用 ExpectedError 类型

错误类型说明触发场景
NO_ERROR无错误,正例预期正常执行
I:ERROR_INVALID_TENSOR_INI_MATCH张量初始化不匹配dtype/format 错误
I:ERROR_INVALID_TENSOR_DIM_NUM维度数量错误dimNum 不符合预期
I:ERROR_INVALID_TENSOR_DIM维度值错误维度值超限/无效
C:ERROR_INVALID_PARAM参数错误非法参数值
S:ERROR_INVALID_TENSOR_DIM输出 Shape 错误输出 tensor shape 不匹配

多设备测试设计原则

设计 CSV 测试用例时,必须同时覆盖 Ascend910B 和 Ascend950 设备。

合并 vs 分离规则
情况SocVersion说明
910B 和 950 完全一致(场景/约束/dtype/format 均相同)Ascend910B;Ascend950合并为一条用例
910B 和 950 存在任何差异分两条,各写各自 SocVersion必须分离
必须分离的场景(不限于以下)
差异类型示例处理方式
dtype 支持不同910B 支持 bf16,950 不支持分两条:910B bf16 / 950 用其他 dtype
format 支持不同910B 支持 ND,950 仅支持 ND_TRANSPOSE分两条,各自指定合法 format
参数约束不同910B quantType=0,1;950 quantType=0分两条,各自合法/非法参数
维度限制不同910B hidden_size≤31424;950 hidden_size≤32768正向/边界分别设计
ExpectedError 不同同一非法输入,910B 报 ERROR_A,950 报 ERROR_B分两条,各自 ExpectedError
性能基准不同910B 和 950 性能预期不同分两条,各自 Performance
设计流程
  1. 先分析接口文档:对比 910B 和 950 的 ACLNN 接口规格,标记所有差异点
  2. 先写共同用例:无差异的场景用 Ascend910B;Ascend950
  3. 再写差异用例:每个差异点,为 910B 和 950 各写一条独立用例
  4. 差异用例命名:{OpName}{场景}910B / {OpName}{场景}950 便于区分

注意:实际运行测试时仅执行 Ascend910B 用例(当前测试环境限制)。Ascend950 用例由用户在 950 设备上手动验证。


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

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

  • <ATB_REPO_PATH>: ATB 仓库路径(如 {your working path}ascend-transformer-boost)

编写步骤

Step 1: 获取接口规格

从用户或官方文档获取算子的:

  • 输入输出定义
  • 参数约束
  • 数据类型支持

Step 2: 阅读源码获取校验逻辑

bash
# 查看参数校验
cat <ATB_REPO_PATH>/src/ops/ops_infer/<op_name>/<op_name>_operation.cpp

# 查找 ERROR_INVALID_* 分支
grep -n "ERROR_INVALID" <ATB_REPO_PATH>/src/ops/ops_infer/<op_name>/<op_name>_operation.cpp

Step 3: 设计正例

覆盖:

  • 典型数据类型的基例
  • 主流模型的常见 shape
  • 边界条件

Step 4: 设计反例

覆盖所有校验分支:

  • 数据类型校验
  • 维度数量校验
  • 维度值校验
  • 参数校验
  • 输出 tensor 校验

Step 5: 设计性能测试

覆盖:

  • 大/中/小 shape
  • 不同数据类型
  • 边界值

Step 6: 创建 CSV 文件(双文件输出)

⚠️ 必须产出两个独立 CSV 文件,不可合并为一个:

bash
# 创建功能用 CSV(正例 + 反例)
touch <ATB_REPO_PATH>/tests/apitest/opstest/csv/<op_name>_func.csv

# 创建性能用 CSV(性能用例)
touch <ATB_REPO_PATH>/tests/apitest/opstest/csv/<op_name>_perf.csv

# 可选:创建合并全量文件
touch <ATB_REPO_PATH>/tests/apitest/opstest/csv/<op_name>_test.csv
拆分规则
文件内容TestType 列用途
{op}_func.csv所有 TestType 非 Performance 的用例(正例+反例)空或 FunctionPhase 5a 前台快速验证
{op}_perf.csv所有 TestType=Performance 的用例PerformancePhase 5a 后台 subagent 运行
{op}_test.csv全部用例(func + perf 合并)混合全量参考 / Phase 5b 全量回归
拆分理由
  • 正例/反例用 -t 1(默认),秒级完成
  • 性能用例默认 400 次迭代,耗时长且可能 OOM
  • 分文件允许 Phase 5a 先快速验证功能,再后台跑性能
  • _func.csv 和 _perf.csv 各有独立完整 header(21 列)

Step 7: 自动引入 Reviewer Agent 评审 ⭐

⚠️ 强制步骤 — Gate 2 之前必须执行

CSV 文件创建后,必须调用 superpowers:requesting-code-review agent 进行评审,不可跳过。

评审内容:

评审维度检查内容
完整度正例/反例/性能是否覆盖所有必要场景
正确性OpParam JSON 是否与设计文档参数映射一致
Shape 一致性InShape/OutShape 是否与 ACLNN 接口约束一致
设备分离910B/950 差异场景是否正确分离 SocVersion
格式规范21 列、`

评审输入:

  • CSV 文件路径
  • 设计文档路径(来自 Phase 1 的 *_replacement_design.md)
  • ACLNN 接口参数约束(来自详设第 2 章)

评审通过标准:

  • 无遗漏的正例场景(dtype/shape/边界)
  • 反例覆盖所有 ERROR_INVALID_* 分支
  • 所有 Shape 经 ACLNN 参数约束预检通过
  • 无格式错误

评审问题修复后,方可进入 Gate 2 用户确认。

Step 8: 运行测试验证

bash
source <CANN_PATH>/set_env.sh
source <ATB_REPO_PATH>/output/atb/set_env.sh --cxx_abi=1
cd <ATB_REPO_PATH>/tests/framework/python/CsvOpsTestTool
python3 atb_csv_ops_test.py -i <CSV_FILE_PATH>

在开始编写前,确认以下问题:

  1. 算子接口:

    • 输入/输出张量的数量和形状?
    • 支持的数据类型?
    • 参数的合法取值范围?
  2. 已有参考:

    • 是否有同类型算子的 CSV 可参考?
    • 是否已有该算子的测试用例?
  3. 特殊约束:

    • 是否有 UB 限制?
    • 是否有内存限制?
    • 是否有特定 shape 要求?

输出模板

## CSV 测试用例设计

### 算子信息
- **算子名称**: XxxOperation
- **接口规格**: [简述]

### 正例列表 (N 个)
| CaseName | InShape | OutShape | 说明 |
|----------|---------|----------|------|
| XxxBase | 128,4096 | 128,2048 | 基例 |
| ... | ... | ... | ... |

### 反例列表 (M 个)
| CaseName | ErrorType | 覆盖分支 |
|----------|-----------|----------|
| XxxErrorDtype | ERROR_INVALID_TENSOR_INI_MATCH | dtype 校验 |
| ... | ... | ... |

### 性能测试列表 (P 个)
| CaseName | InShape | 说明 |
|----------|---------|------|
| XxxPerfLarge | 2048,16384 | 大 shape |
| ... | ... | ... |

### 统计
- 正例: N 个
- 反例: M 个
- 性能测试: P 个
- 总计: N+M+P 个

### 保存路径
- **功能 CSV**: `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_func.csv`(正例+反例)
- **性能 CSV**: `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_perf.csv`(性能用例)
- **合并 CSV**(可选): `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_test.csv`
- **备份/预览**: `{WORKING_DIR}/`

Human in the Loop: 用户确认检查点 ⭐

⚠️ 强制检查点 - 不可跳过

CSV 用例设计完成后,必须等待用户确认后方可进入实际迁移阶段。

确认前准备

  1. 保存 CSV: 将生成的 CSV 用例保存至 ATB 仓库目录

    • 功能 CSV: {ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_func.csv(正例+反例)
    • 性能 CSV: {ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_perf.csv(性能用例)
    • 合并 CSV(可选): {ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_test.csv
  2. 准备确认清单: 供用户逐项确认

用户确认检查表

markdown
## CSV 用例确认 - {OpName}

### 待确认文件
- **功能 CSV**: `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_func.csv`(正例 X 个 + 反例 Y 个)
- **性能 CSV**: `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_perf.csv`(性能 Z 个)

### 确认检查表
| 检查项 | 说明 | 用户确认 |
|--------|------|----------|
| 正例覆盖典型场景 | 包含 float16/bf16 基础用例,主流模型常见 shape | [ ] |
| 反例覆盖所有校验分支 | 覆盖所有 ERROR_INVALID_* 类型 | [ ] |
| 性能测试覆盖大小 shape | 包含大/中/小 shape 测试 | [ ] |
| CSV 已拆分为双文件 | `_func.csv` 和 `_perf.csv` 各自独立 | [ ] |
| CSV 格式符合规范 | 列数=21,分隔符=|,无多余空格 | [ ] |
| 数据类型名称正确 | 使用 data_generation.py 支持的名称 | [ ] |
| ExpectedError 类型正确 | 与参数校验逻辑匹配 | [ ] |
| 可进入实际迁移阶段 | CSV 用例已通过审查 | [ ] |

### 确认方式
- **通过**: 回复 "确认通过" 或逐项打勾确认
- **修改**: 指出具体问题,返回修改后重新确认

### 后续步骤
确认通过后,将进入 Phase 3: 实际迁移阶段
- 下一步调用: `atb-aclnn-operator-migration`

**⚠️ 未收到用户确认前,禁止进入实际迁移阶段**

向用户呈现方式

markdown
我已生成 {OpName} 算子的 CSV 测试用例,已拆分为两个独立文件,请确认以下内容:

📄 **功能 CSV**: `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_func.csv`
   - 正例: N 个
   - 反例: M 个
📄 **性能 CSV**: `{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_perf.csv`
   - 性能测试: P 个

Phase 5a 测试时将分两步:
1. 前台跑 _func.csv(秒级完成)
2. 后台 subagent 逐个跑 _perf.csv(避免 OOM)

请检查:
1. 正例是否覆盖了所有典型场景和数据类型?
2. 反例是否覆盖了所有参数校验分支?
3. 性能测试的 shape 选择是否合理?
4. CSV 拆分是否正确(正例/反例在 _func,性能在 _perf)?

回复 "确认通过" 进入实际迁移阶段,或指出需要修改的地方。
文件类型路径说明
功能 CSV{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_func.csv正例+反例,Phase 5a 前台跑
性能 CSV{ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_perf.csv性能用例,Phase 5a 后台 subagent 跑
合并 CSV(可选){ATB_REPO_PATH}/tests/apitest/opstest/csv/{op_name}_test.csv全量参考

变量说明:

  • ATB_REPO_PATH: ATB 仓库路径
  • WORKING_DIR: working_files 目录
  • op_name: 算子名称小写(如 {xxx}quant)

执行结果

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

检查点检查表

步骤检查点描述状态
-正例设计完成✅ PASS / ❌ FAIL / ⏭️ SKIP
-反例设计完成✅ PASS / ❌ FAIL / ⏭️ SKIP
-性能测试设计完成✅ PASS / ❌ FAIL / ⏭️ SKIP
-CSV 文件已创建(双文件)✅ PASS / ❌ FAIL / ⏭️ SKIP
-CSV 已拆分为 _func.csv 和 _perf.csv✅ PASS / ❌ FAIL / ⏭️ SKIP
-用户已确认 CSV 用例 ⭐⬜ 待确认

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

问题列表(若有)

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

执行摘要

  • 执行时间:
  • 算子名称:
  • 正例数量:
  • 反例数量:
  • 性能测试数量:
  • 通过率:

Frequently asked questions

What does the Atb Csv Testcase Generator AI skill do?

ATB CSV 测试用例生成技能。当用户需要为 ATB 算子创建 CSV 格式的泛化测试用例时调用此技能。 覆盖:正例设计、反例设计、性能测试用例、CSV 格式规范。

Why use Atb Csv Testcase Generator on TypingMind?

Because you install it once and use it with any model. Atb Csv Testcase Generator is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Atb Csv Testcase Generator in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Ascend/agent-skills/tree/master/skills/ascend-transformer-boost/skills/atb-csv-testcase-generator. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Atb Csv Testcase Generator?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Atb Csv Testcase Generator?

As many as you like. As long as a model supports skills, you can use Atb Csv Testcase Generator with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Atb Csv Testcase Generator AI skill free?

Yes. It is published on GitHub by Ascend under the MulanPSL-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇