cake-code-review

Review AscendC kernel code for red-line violations and algorithm correctness.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? AscendC operator kernels for Ascend NPU hardware are prone to structural defects (division by zero, buffer overruns, null pointer dereferences, overflow) and algorithm-level gaps (broken normalization chains, unconsumed reduction results) that cause crashes or silent data corruption. This Skill automates a five-phase review workflow that detects, prioritizes, fixes, and verifies these issues before evaluation. ## Core Features & Use Cases - API Compliance Precheck: Dynamically derives grep patterns from api-dispatch.json to scan kernel code against a blacklist (e.g., GlobalTensor::SetValue, raw DataCopy) and dispatch best-practice reference docs only for APIs actually used. - Structural Red-Line Review: Scans op_kernel and op_host code for 7 mandatory red lines (division-by-zero, bounds, overflow, initialization, null pointers, resource matching, data races) plus TopN issues like stdlib math bans, PipeBarrier namespace errors, and tiling field mismatches, outputting JSON and Markdown reports with P0–P3 severity. - Algorithm Correctness Check: Verifies normalization-chain completeness, denominator safety invariants, iterative update completeness, and reduction result consumption. - Fix and Verify Pipeline: Applies standard repair patterns in P0→P3 priority order, generates rectification reports, then runs compile → UT → ST three-layer verification. - Use Case: After lowering a DSL operator to AscendC, run the full workflow on the operator directory to receive a rectification report, patched source code, and a verification report confirming 100% compile/UT/ST pass rates. ## Quick Start Use cake-code-review to check the operator at output/my_operator and fix any red-line violations it finds.

Frequently Asked Questions about cake-code-review

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

FAQPage Schema
How do I review AscendC kernel code for safety violations?

Run the cake-code-review workflow on the operator directory containing op_kernel and op_host sources. It executes an API compliance precheck, structural red-line scan, and algorithm correctness check, producing a prioritized JSON and Markdown issue list.

What coding red lines does AscendC operator review check?

The review enforces seven red lines: division-by-zero protection, array bounds checks, int64 overflow protection, variable initialization, null pointer guards, buffer resource matching, and data race prevention. It also flags TopN issues like stdlib math functions, PipeBarrier namespace errors, and tiling field name mismatches.

Which APIs are blacklisted in AscendC kernel code?

GlobalTensor::SetValue and GlobalTensor::GetValue are banned in production for poor performance, and direct DataCopy between GM and UB is banned in favor of DataCopyPad for non-aligned data. AscendC::printf is allowed only for debugging and must be removed before merging.

Can the review fix issues automatically or only report them?

Both modes are supported. The fix phase applies standard repair patterns in P0 to P3 priority order, patches source code in place, updates operator docs, and generates a rectification report; a review-only mode reports issues without modifying code.

Does AscendC verification require NPU hardware?

Yes, the verify phase requires a CANN environment and Ascend 910B-class NPU machine to compile kernels and run UT and ST tests. It cannot validate NPU operators in a pure x86 environment, and numerical accuracy evaluation is delegated to a separate evaluation skill.