skills/ascendc-operator-testcase-gen/SKILL.md
完成AscendC算子验证用例生成 - 帮助用户完成testcase设计。当用户提到用例设计、泛化用例生成、算子标杆、UT用例、精度用例、性能用例时,使用此skill。
npx skillsauth add Ascend/agent-skills ascendc-operator-testcase-genInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
根据算子设计文档(design.md)生成验证用例和标杆,供后续UT代码生成、精度验证以及性能验证skill使用。
在 ascendc-operator-design 创建design.md之后、ascendc-operator-ut-gen/ascendc-operator-precision-eval/ascendc-operator-performance-eval调用之前调用。
调用此技能时,必须明确提供以下参数:
参数1:设计文档
design.md设计用例MANDATORY: 在生成测试用例之前,必须读取以下参考文档:
templates/test-cases-template.md — 测试用例格式参考design.md — 用户提供的算子设计文档SUPPORTED_DTYPES必须包含design.md中[参数说明]支持的所有数据类型根据算子支持的维度以及算子类型,从以下维度池中选取适合的 shape,组成 TEST_SHAPES 列表。
MUST 根据算子实际支持的维度来选,不支持的维度不要选。
| 维度 | 推荐 shape | 适用算子类型 | |------|-----------|-------------| | 1D | (128,), (1024,), (4096,), (8192,) | elementwise, reduction | | 2D | (32, 512), (64, 768), (128, 1024) | elementwise, matmul, linear | | 3D | (8, 16, 64), (4, 128, 256) | elementwise, attention, conv1d | | 4D | (4, 8, 32, 16), (2, 64, 32, 32) | conv2d, elementwise | | 5D | (2, 3, 4, 5, 6) | conv3d, elementwise |
shape 不要过大:推荐单个 shape 元素数 ≤ 200K。
TEST_SHAPES = [
("category_name", "description", (dim0, dim1, ...)),
# ...
]
Category 名称自定义,建议按维度或场景命名。示例:
# elementwise 算子(支持任意维度)
TEST_SHAPES = [
("1D", "128 elements", (128,)),
("1D", "1024 elements", (1024,)),
("1D", "4096 elements", (4096,)),
("1D", "8192 elements", (8192,)),
("2D", "32x512", (32, 512)),
("3D", "8x16x64", (8, 16, 64)),
("3D", "4x128x256", (4, 128, 256)),
("4D", "4x8x32x16", (4, 8, 32, 16)),
]
根据算子支持的维度以及算子类型,从以下维度池中选取适合的 shape,组成 GENERAL_SHAPES 列表。
MUST 根据算子实际支持的维度来选,不支持的维度不要选。
小Shape场景(边界测试、极小值、非对齐测试)
| 维度 | 小 shape | 测试目的 | |------|---------|---------| | 1D | (1,), (2,), (4,), (8,) | 极小元素、边界值 | | 1D | (3,), (5,), (7,) | 非对齐长度 | | 2D | (1, 1), (2, 2), (4, 4) | 极小2D tensor | | 2D | (1, 128), (2, 256) | 单行/单列场景 | | 3D | (1, 1, 1), (2, 2, 2) | 极小3D tensor | | 3D | (1, 8, 64), (2, 16, 128) | 单batch场景 |
大Shape场景(生产环境、压力测试、模型典型场景)
| 维度 | 大 shape | 适用模型 | 元素数 | |------|---------|---------|--------| | 1D | (3072,), (4096,) | BERT FFN中间层 | 3K-4K | | 1D | (5120,), (6400,) | GPT-2 FFN中间层 | 5K-6K | | 2D | (512, 768) | BERT-base full sequence | 393K | | 2D | (512, 1024) | BERT-large full sequence | 524K | | 2D | (1024, 768) | GPT-2 sequence | 786K | | 2D | (1024, 1024) | GPT-2 medium sequence | 1M | | 2D | (1024, 1600) | GPT-2 XL sequence | 1.6M | | 3D | (8, 512, 768) | BERT-base batch | 3.1M | | 3D | (8, 197, 768) | ViT-base batch | 1.2M | | 3D | (16, 1024, 1024) | GPT-2 large batch | 16.7M |
注意事项:
- 生产环境、模型典型场景推荐shape应视每个算子具体应用场景而变化
- 小shape用于边界测试,确保算子在极小输入下正确工作
- 大shape用于性能测试和验证大规模数据的正确性
- 元素数超过200K的shape仅用于泛化测试,不在常规测试中使用
GENERAL_SHAPES = [
("Small", "description", (dim0, dim1, ...)),
("Large", "description", (dim0, dim1, ...)),
# ...
]
Category 建议使用 "Small" 和 "Large" 区分场景。示例:
# elementwise 算子(支持任意维度)
GENERAL_SHAPES = [
# 小Shape场景
("Small", "single element", (1,)),
("Small", "tiny vector 2", (2,)),
("Small", "tiny vector 4", (4,)),
("Small", "unaligned length 3", (3,)),
("Small", "unaligned length 5", (5,)),
("Small", "2x2 matrix", (2, 2)),
("Small", "1x128 single row", (1, 128)),
("Small", "1x1x1 scalar", (1, 1, 1)),
("Small", "1x8x64 single batch", (1, 8, 64)),
# 大Shape场景(生产环境)
("Large", "BERT-base FFN 3072", (3072,)),
("Large", "BERT-large FFN 4096", (4096,)),
("Large", "BERT-base 512x768", (512, 768)),
("Large", "BERT-large 512x1024", (512, 1024)),
("Large", "GPT-2 1024x768", (1024, 768)),
("Large", "GPT-2 1024x1024", (1024, 1024)),
("Large", "ViT-base 8x197x768", (8, 197, 768)),
]
基于收集的信息,读取 templates/test-cases-template.md 模板,填充所有章节,输出到 csrc/ops/[op-name]/test/[op-name]-test-cases.md。
输出位置: ascend-kernel/csrc/ops/[op-name]/test/[op-name]-test-cases.md
ascendc-operator-precision-eval 负责)ascendc-operator-performance-eval 负责)ascend-kernel/csrc/ops/[op-name]/test/[op-name]-test-cases.mdtesting
Kubernetes 集群健康检查与安全修复 — 诊断问题,用户确认后执行修复
tools
昇腾NPU CANN Toolkit+Kernels+NNAL安装部署技能。支持从官网下载run包安装和从Docker镜像提取两种方式,覆盖驱动检查、包下载、安装、环境变量配置与验证全流程。当用户需要安装CANN全套组件或指定版本CANN到自定义路径时调用。
development
编译 ATB (Ascend Transformer Boost) 测试框架。当用户需要编译 ATB 测试框架、 运行 CSV 测试、或构建 atb_test_framework 时调用。支持全量编译(含第三方依赖克隆与源替换) 和增量编译两种模式。需在 Docker 容器内配合 CANN 环境执行。
databases
ATB OPS→ACLNN 迁移标准化工作流主模板。整合前置学习、设计文档生成、CSV用例设计、 实际迁移、编译验证、测试验证全流程,提供明确的阶段 Gates 和用户确认机制。