ascendc-op-patterns

Selects AscendC kernel implementation skeletons for common operator families on Ascend hardware.

6|1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/xchang1121/op-autoresearch --skill ascendc-op-patterns-xchang1121
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ascendc-op-patterns
Source: https://github.com/xchang1121/op-autoresearch/tree/main/skills/ascendc/guides/ascendc-op-patterns
Command: npx skills add https://github.com/xchang1121/op-autoresearch --skill ascendc-op-patterns-xchang1121

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When writing or optimizing AscendC kernels for Ascend NPU backends, choosing the wrong initial kernel structure wastes iteration cycles. This Skill provides ready-made implementation templates for common operator families so an agent or developer can pick a correct skeleton before tuning performance. ## Core Features & Use Cases - Operator Family Templates: Provides skeletons for elementwise, broadcast, reduction, softmax-like, gather/scatter indexed, and matmul-with-epilogue operators. - Shape-Based Fast-Path Classification: Includes a host-side pattern classification scheme (same-shape, scalar broadcast, last-dim broadcast, small reduction, single-tile reduction) with a generic fallback, plus guidance on keeping mode branches outside the inner loop. - Numerical and Tiling Rules: Documents UB capacity limits, tail masking, fp32 accumulation for fp16/bf16 reductions, softmax numerical stability, and Cube/Vector load balancing for matmul epilogues. - Use Case: During a batch kernel-optimization run for a new reduction operator, use this Skill to decide between per-core row reduction, segmented multi-core reduction with workspace merge, or a single-tile UB path before writing any device code. ## Quick Start Ask the agent to use the ascendc-op-patterns skill to choose an initial kernel skeleton for your operator's shape and semantics before editing the kernel math.

Frequently Asked Questions about ascendc-op-patterns

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

FAQPage Schema
How do I choose an AscendC kernel structure for a new operator?▼

Classify the operator into a family such as elementwise, broadcast, reduction, softmax-like, indexed, or matmul-with-epilogue, then pick the matching skeleton. Start with a correct direct-invoke kernel and only apply profiling-driven optimizations afterward.

How to implement a reduction kernel in AscendC for large rows?▼

Split the reduction into per-core segmented partial reductions, then merge partials with a second stage using workspace or atomics. Use fp32 accumulators for fp16/bf16 inputs when reference precision requires it, and mask invalid lanes in the final tile.

Which Ascend hardware does this operator pattern guide support?▼

The templates target the Ascend backend with the AscendC DSL on Atlas A2, Atlas A3, and Atlas A5 hardware. Rules reference AscendC concepts such as UB capacity, DataCopy granularity, and Cube/Vector units.

Should broadcast operators always use general index mapping in AscendC?▼

No. General index mapping often becomes scalar-bound, so fast paths for same-shape, scalar, and last-dimension broadcast should be checked first. Reserve the general index-mapping fallback for shapes that match no fast path.

Why does my AscendC softmax kernel overflow on large values?▼

Overflow happens when the numerically stable max-subtraction pass is skipped. The stable pattern is reduce_max, then exp(x - max), then reduce_sum, then normalize; removing a pass to save time breaks overflow protection.