dsl-lowering

Translates operator DSL into compilable AscendC kernel code through multi-pass transformations.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing AscendC kernels for Ascend NPU hardware by hand is error-prone and slow. This Skill automates the lowering of a high-level operator DSL into working AscendC host and kernel code, handling tiling, buffer management, data alignment, and multi-dtype support while automatically repairing compilation errors. ## Core Features & Use Cases - Multi-Pass Lowering Pipeline: Sequentially applies tiling_pass, kernel_config_pass, kernel_pass, entry_pass, and an optional multi_dtype_pass, compiling after each pass. - Automatic Error Recovery: Diagnoses compilation failures using curated error-correction references and retries up to three times per pass. - Hardware-Correct Patterns: Enforces dynamic core-count querying, pivot-based work distribution, DataCopyPad for non-aligned transfers, correct Cast modes for bfloat16, and pipeline barriers. - Use Case: Given a DSL file describing a LeakyRelu or matmul-style operator, generate a complete AscendC project (host tiling, op definition, kernel) that compiles for ascend910b and supports float32, float16, and bfloat16 variants. ## Quick Start Translate the operator DSL in output/my_op/my_op_dsl.py into AscendC code and compile each pass until the project builds successfully.

Frequently Asked Questions about dsl-lowering

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

FAQPage Schema
How do I convert an operator DSL into AscendC kernel code?

Run the multi-pass lowering pipeline: tiling_pass moves scalar computation to host tiling, kernel passes generate Init and Process methods, and entry_pass creates the dispatch function. Each pass compiles via source build.sh, with automatic repair on failure.

How do I handle non-32-byte-aligned data transfers in AscendC?

Replace AscendC::DataCopy with AscendC::DataCopyPad whenever the transfer size is not a multiple of 32 bytes. Pass DataCopyPadParams with block count and byte length, plus padding parameters for GM-to-UB transfers.

Does AscendC support bfloat16 computation on Ascend910b?

bfloat16 is supported for I/O, but Muls, Mul, and Add are not supported for bfloat16_t on dav_c220. Upcast to float32 for computation, then downcast using Cast with CAST_RINT mode, since CAST_NONE for f32-to-bf16 produces garbage output.

Why does my AscendC build silently stop in docker or tmux?

Running bash build.sh creates a new process group that receives SIGTTIN/SIGTTOU signals, causing cmake and make to stop silently. Use source build.sh instead so compilation runs in the current shell.

Why does my AscendC kernel produce wrong results only for the last tile?

This happens when results are overwritten instead of accumulated across tiles. Read the current value with GetValue, add the new tile result, and write it back so all tiles contribute to the final output.

How do I add float32, float16, and bfloat16 support to one AscendC kernel?

Use the DTYPE macro injected by the build system with an ifndef guard, replace I/O types with the macro, and branch with if constexpr in template helper functions. Allocate float32 conversion TBufs and add SetFlag/WaitFlag pipeline barriers between MTE and VEC stages.