CANN/cannbot-skills Custom操作机制总览

📅 2026/7/11 16:52:02
CANN/cannbot-skills Custom操作机制总览
Custom 操作机制总览【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills关键词Custom Op, BuiltinInfo, __builtin_gather_load, __builtin_index_select, 自定义操作概述HIVM Custom 操作机制提供了一种通用的扩展接口允许用户在现有操作无法满足需求时编写自定义实现。Custom 操作支持两种粒度hir.custom单 Pipe 自定义操作在单个 Pipeline 上执行hir.custom_macro跨 Pipe 自定义宏操作涉及多个 PipelineCustom 操作通过name属性标识操作类型编译器根据 name 查找对应的实现。部分 name 以__builtin开头的是内置操作编译器自带实现其他 name 需要用户提供实现。Builtin 机制内置操作Builtin是编译器自带的 Custom 操作实现name 以__builtin开头。当前支持的内置操作Builtin Name说明Core TypePipe__builtin_gather_loadGather Load 操作VECTORPIPE_V__builtin_index_selectIndex Select 操作VECTORPIPE_VBuiltinInfo 结构每个 Builtin 操作都有对应的BuiltinInfo结构包含字段CustomOpCustomMacroOpcoreTypeTCoreTypeTCoreTypepipe / inPipePIPEPIPE--outPipe (PIPE)vfModeVFModeVFModegetOpLibraryCallNamefunctionstring(Op)functionstring(Op)gmAddrArgsIndicesSmallVectorsize_tSmallVectorsize_tCustom 操作属性Custom 操作通过属性传递必要信息必需属性属性说明hivm.tcore_type执行的 Core 类型参见 TCoreTypeAttrhivm.vf_modeVector 单元运行模式参见 VFModeAttrCube Core 时忽略CustomOp 特有属性属性说明hivm.pipe执行的 Pipe参见 PipeAttrCustomMacroOp 特有属性属性说明hivm.pipe_in输入 Pipehivm.pipe_out输出 Pipe可选属性属性说明gm_addr_args_indicesI32 数组指示哪些参数包含 GM 纯地址lowering 时保留地址值操作列表操作助记符详细文档CustomOphir.custom01-custom-op.mdCustomMacroOphir.custom_macro02-custom-macro-op.md相关文档源码参考HIVMOps.td测试用例custom-op.mlir【免费下载链接】cannbot-skillsCANNBot 是面向 CANN 开发的用于提升开发效率的系列智能体本仓库为其提供可复用的 Skills 模块。项目地址: https://gitcode.com/cann/cannbot-skills创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考