用途:依据 CATLASS 算子设计文档生成算子工程交付件,工作流为设计文档解析→Catlass 实现参考选型→op_host 生成→op_kernel 生成→test_aclnn 生成→质量验证。设计文档是唯一依据,须 100% 遵守,涵盖算子名(含 catlass 子串、snake_case 目录与 CamelCase 类名一致)、I/O 与 dtype、核心组件(ArchTag、BlockMmad、BlockEpilogue、BlockScheduler、Kernel)、参考 example 路径与选型理由、TilingKey 分支、Workspace 固定写法。前置条件:设计文档含算子名、I/O、dtype、转置、参考 example、Kernel/Block/Epilogue;OPS_PROJECT_ROOT 已定且含 build.sh、ops/;catlass/ 含 include/、examples/,缺则在工程根克隆;条件不明时追问用户。实现参考选型在 catlass/examples/ 中找最接近示例,复用 Kernel/Block/Epilogue,op_kernel 须 Device 调用,tiling 常量、Workspace、TILING_KEY_IS 分支与 Host 侧对齐。端到端步骤:Step 0 在 OPS_PROJECT_ROOT 执行 bash build.sh --genop=ops/<op_name> 生成骨架;Step 1 清理模板并按 compile-options.md 配置 ascendc_config.json;Step 2 对照设计文档列清单;Step 3 锁定实现参考;Step 4 写 op_host 的 _tiling.h/tiling.cpp、_def.cpp、infershape.cpp;Step 5 按 kernel-rules.md 写 op_kernel(GET_TILING_DATA、TILING_KEY_IS、Device 调用、#define K_MAX_SHAPE_DIM 0、勿 #include tiling.h);Step 6 按 example-rules.md 覆盖 examples/test_aclnn<op_name>.cpp;Step 7 结构自检与编译运行验证。常见陷阱:禁止跳过 --genop、tiling/infershape 并进 def、漏 IMPL_OP* 注册、def 里 SetTiling/SetInferShape、目录名无 catlass、Kernel 内用 if 代替 TilingKey、op_kernel 用 DeviceGemm 或 #include tiling.h、对 Gemm 仅用 shape 推断转置、忘记配置 Catlass 编译选项;应始终先 opgen 再覆盖、三文件分文件注册、严格按设计文档选型、改算子后 --pkg 安装再跑示例。references 含 compile-options.md、code-structure.md、example-rules.md、tiling-rules.md、def-rules.md、infershape-rules.md、kernel-rules.md、custom-epilogue.md;参考资料含 catlass/examples/advanced/basic_matmul_aclnn、catlass/examples/03_matmul_add、ascendc-operator-compile-debug、catlass-operator-design。限制:具体平台、收费与效果资料暂未提供。
catlass-operator-code-gen
编程与开发
更新于 10-15 19:58