CANNHACC方言总览

📅 2026/7/11 13:32:42
CANNHACC方言总览
HACC 方言总览【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills1. 简介HACCHeterogeneous Async Computing Call异构异步计算调用方言是 AscendNPU-IR 中用于描述 Host-Device 异构计算模型的核心方言。它定义了函数的 Host/Device 归属、NPU 设备规格参数、Kernel 参数类型以及 Host-Device 函数绑定关系为后续的编译流程提供了异构语义基础。方言名称haccC 命名空间::mlir::hacc依赖方言mlir::DLTIDialect2. 核心概念概念说明HACCFuncType函数的 Host/Device 归属分类DeviceSpecEnumNPU 硬件规格参数枚举TargetDeviceSpecAttr目标设备规格属性映射具体 NPU 型号KernelArgTypeKernel 参数类型分类HostFuncTypeHost 端函数角色分类HACCFunctionInterface异构函数接口提供查询与设置方法3. 源码位置文件路径方言基类HACCBase.td属性与枚举HACCAttrs.td接口定义HACCInterfaces.td变换 PassPasses.td4. 方言定义def HACC_Dialect : Dialect { let name hacc; let description [{ Heterogeneous Async Computing Call (HACC) dialect. }]; let cppNamespace ::mlir::hacc; let useDefaultAttributePrinterParser 1; let dependentDialects [mlir::DLTIDialect]; }5. 与其他方言的关系HACC 方言 ├── 被 HFusion 方言依赖HFusion 依赖 hacc::HACCDialect ├── 被 Scope 方言间接使用scope.scope 可携带 tcore_type 等属性 ├── 与 DLTIDialect 协作设备规格通过 DLTI 机制存储 └── 为 HIVM 层提供 Host-Device 调用约定基础6. 典型 IR 示例module { func.func host_kernel(%arg0: tensor?x?xf16) attributes {hacc.function_kind #hacc.function_kindHOST} { return } func.func device_kernel(%arg0: tensor?x?xf16, %arg1: i64 {hacc.arg_type #hacc.arg_typetiling_data}) attributes {hacc.function_kind #hacc.function_kindDEVICE, hacc.tiling_function #hacc.tiling_functiontiling_func} { return } }7. 文档索引文档内容01-function-management.mdHOST/DEVICE 函数类型与 HACCFunctionInterface02-device-specification.mdNPU 设备规格参数与型号映射03-kernel-args.mdKernel 参数类型完整列表04-host-device-binding.mdHost-Device 函数绑定关系05-transforms.mdHACC 变换 Pass【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考