Core workflow
设计文档解析 → Catlass 实现参考选型 → op_host 生成 → op_kernel 生成 → test_aclnn 生成 → 质量验证
Design document compliance specification (CRITICAL)
The design document is the sole basis for code generation and must be followed 100%.
| Section | Required content | Verification method |
|---|---|---|
| Operator name | Contains catlass substring, snake_case directory name consistent with CamelCase class name |
Directory, OpDef, and test_aclnn naming are consistent |
| I/O and dtype | Input/output shape, dtype, format | OpDef and test_aclnn tensor are consistent |
| Core components | ArchTag, BlockMmad, BlockEpilogue, BlockScheduler, Kernel types | op_kernel and custom-epilogue.md are consistent |
| Reference example | Specified catlass example path and rationale for selection | Implementation is consistent with the selection (not a wholesale paste) |
| TilingKey | Each branch corresponds to dtype/transpose, etc. | Host SetTilingKey and TILING_KEY_IS correspond one-to-one |
| Workspace | Fixed wording | See kernel-rules.md |
Prerequisites
| Check item | Description |
|---|---|
| Design document | Contains operator name, I/O, dtype, transpose, reference example, Kernel/Block/Epilogue |
| Project | OPS_PROJECT_ROOT is finalized, contains build.sh、ops/ |
| Catlass | <OPS_PROJECT_ROOT>/catlass/ contains include/、examples/; if missing, clone in the project root |
When conditions are unclearAskthe user.
Catlass implementation reference selection
In catlass/examples/ select according to the design documentthe implementation reference(read the structure, copy the component composition approach,nottreat the example as a ops/ migration source):
- Find the example closest to the operator form
- Determine the reusable Kernel/Block/Epilogue;the operator project op_kernel must use the Device call
- Align tiling constants, Workspace, and
TILING_KEY_ISbranches with the Host side
End-to-end steps
Step 0: Generate skeleton (mandatory)
In OPS_PROJECT_ROOT:bash build.sh --genop=ops/<op_name>
Step 1: Clean templates, configure compilation options
Delete unused templates; according to compile-options.md configure ascendc_config.json
Step 2: List a checklist against the design document
Operator name, I/O, dtype, transpose, reference path, Kernel/Block/Epilogue, Workspace, TilingKey branches
Step 3: Lock the implementation reference
Same as "Catlass implementation reference selection" above
Step 4: Write op_host
Generate 3 categories and 4 files:
*_tiling.h/*_tiling.cpp: according to tiling-rules.md*_def.cpp: according to def-rules.md*_infershape.cpp: according to infershape-rules.md
Step 5: Write op_kernel
According to kernel-rules.md:GET_TILING_DATA、TILING_KEY_IS, Device call,#define K_MAX_SHAPE_DIM 0, do not #include tiling.h
Step 6: Write test_aclnn
According to example-rules.md cover examples/test_aclnn_<op_name>.cpp
Step 7: Verify
- Structural self-check:code-structure.md
- Compile and run:ascendc-operator-compile-debug
Common pitfalls
NEVER: skip --genop; merge tiling/infershape into def; miss IMPL_OP_* registration; in def SetTiling/SetInferShape; no directory name catlass; use within Kernel if instead of TilingKey; op_kernel uses DeviceGemm;op_kernel #include tiling.h; for Gemm only use shape inference for transpose; forget to configure in ascendc_config.json the Catlass compilation options
ALWAYS: opgen first then overwrite; register in three separate files; strictly follow the design document for component selection; configure in ascendc_config.json the Catlass compilation options; after modifying the operator --pkg install then run the example
references index
| File | Content |
|---|---|
| compile-options.md | Compilation option configuration |
| code-structure.md | Directory tree, file responsibility index |
| example-rules.md | test_aclnn usage |
| tiling-rules.md | tiling.h / tiling.cpp |
| def-rules.md | def.cpp |
| infershape-rules.md | infershape.cpp |
| kernel-rules.md | Catlass dependencies and Device invocation |
| custom-epilogue.md | Custom Tile Epilogue |
References
| Document/Directory | Purpose |
|---|---|
| catlass/examples/advanced/basic_matmul_aclnn | Engineering op_host / op_kernel / test organization comparison |
| catlass/examples/03_matmul_add | MatmulEpilogue + BlockEpilogue combination reference |
| ascendc-operator-compile-debug | Compile, install, run example |
| catlass-operator-design | Design document |