ascend-call-generation

Generate AscendC operator project scaffolds with pybind bindings and CMake configuration from PyTorch code.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill ascend-call-generation-wangwindow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ascend-call-generation
Source: https://github.com/WangWindow/CANN-BatchMatMulMaxsum/tree/main/.agents/skills/ascend-call-generation
Command: npx skills add https://github.com/WangWindow/CANN-BatchMatMulMaxsum --skill ascend-call-generation-wangwindow

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Manually writing the pybind bridge code, project JSON configuration, and CMake scaffolding for a custom AscendC NPU operator is repetitive and error-prone, especially around dtype mapping and output shape allocation. This Skill automates that generation from functional PyTorch code. ## Core Features & Use Cases - Project JSON Generation: Builds the msopgen project JSON with inputs, outputs, and attributes mapped 1-to-1 from the module_fn signature, including all dtypes collected from op_desc.json test cases. - Pybind Bridge Code: Generates C++ pybind11 code with correct output tensor shape allocation (same-shape, reduced-dim, multi-input derived, or scalar) and TORCH_LIBRARY_IMPL registration. - Project Scaffolding: Runs gen_project.py via msopgen to create the full AscendC CMake project at output/{op_name}/{OpNameCustom}/, with stale libcust_opapi.so cleanup patched into build.sh. - Use Case: After converting a PyTorch reduction operator to functional form, invoke this Skill to produce the complete AscendC project skeleton ready for kernel implementation. ## Quick Start Generate the AscendC project scaffold for my functional PyTorch operator by reading {op_name}_functional.py and creating the project JSON, pybind code, and msopgen project in the output directory.

Frequently Asked Questions about ascend-call-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an AscendC operator project from PyTorch code?

Provide the functional PyTorch file ({op_name}_functional.py) and this Skill generates the project JSON, pybind C++ bridge, and Python wrapper, then runs gen_project.py with msopgen to create the CMake project at output/{op_name}/{OpNameCustom}/.

How to map PyTorch dtypes to AscendC project JSON types?

Collect all unique dtypes from op_desc.json shape_info and test_cases, then convert to CANN names: float32 becomes "float", while float16, bfloat16, and int32 keep their names. Every type entry needs a matching format entry, typically "ND".

Why does my AscendC operator fail with EZ1001 dtype not supported?

Error EZ1001 means a dtype is missing from the project JSON "type" array, so the build system never compiled that variant. Verify the type array length covers every unique dtype found in the test_cases of op_desc.json.

How should output tensor shape be allocated in pybind code?

Use at::empty_like only when output matches the input shape. For reductions, modify the input shape at the reduced dimension; for matmul, compute the shape from both inputs; for scalar outputs use at::empty({}, input.options()).

What operator categories does this scaffold generation support?

It targets pure Vector operators and ships reference examples for pooling (average_pooling2d), reduction (sum over a dimension), loss (mse_loss), matmul/linear, and normalization (layer_norm). Cube-heavy fused operators may need manual kernel work beyond the scaffold.