已合并
【PR】: autofuse支持extendconv2d #1669
【PR】: autofuse支持extendconv2d #1669
已合并
hemahema创建于 8月6日
hemahema
hemahema
8月6日

Pull Request

描述

autofuse原有支持Conv2DV2的自动融合,现新增对ExtendConv2D自动融合的支持。
主要变更:

  • ASCIR 算子:在 v1/v2 注册 ExtendConv2D / ExtendConv2DBias / ExtendConv2DScale / ExtendConv2DBiasScale,补充 round_mode、enable_relu0、fixed_shift_value 等 IR 属性;GE bridge 识别这些类型。
  • 属性与构图工具:ParseConv2DAttr / IsConv2DGraphType 覆盖 extend 及可选 bias、offset_w、scale0;GetCubeAttributes 向外导出 is_extend_conv2d、has_scale0、round_mode 等字段。
  • Codegen / Kernel:conv2d_v2 对齐 ActConvConfig 模板维(含 BatchOne、SmallKernel),增加 scaleGM 槽位;Cube tiling 与 CV fusion 向量侧支持 extend 场景(含 tmpTilingData.nL0)。顺带拆分 cube tiling 超大函数,满足规范。
  • Host 编译:ConvArgsConfig 区分 Conv2DV2 紧凑入参和 ExtendConv2D 的 10 槽逻辑输入(未连接的 bias/scale 填空)。
  • TilingKey:更新 conv2d_v2_tilingkey_cv.h,与新模板维一致。
  • 测试:补充 UT/ST,覆盖属性解析、codegen tiling、Python cube attributes、compile 入参槽位和 backend e2e 构图。

变更类型

请选择本次引入的变更类型:

关联的Issue

如何测试

描述测试此变更的步骤和前提条件:
1.
2.

核对清单

其他信息

在此添加任何其他关于本次 PR 的说明。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 hemahema 的贡献)
hemahemahemahema
8月6日 添加了label:enhancement
hemahemahemahema
8月6日 创建了 pull request,commit ad313550
atomgit-bot
atomgit-bot
8月6日 评论:

变更摘要

此 PR 主要为 autofuse 框架新增了 ExtendConv2D 系列算子的支持,包括 ExtendConv2DExtendConv2DBiasExtendConv2DScaleExtendConv2DBiasScale 四种 variant。同时重构了现有 Conv2D 的 codegen、tiling 和 Python 编译流程,引入了 optional 输入占位机制(nullptr_inputs_index)、scale0 输入支持、以及新的模板参数,以适配更灵活的卷积融合场景。

主要改动

  • 新增四种 ExtendConv2D ASC IR 算子注册:在 ascir_builtin_ops_v1.cppascir_builtin_ops_v2.cpp 中分别注册 ExtendConv2DExtendConv2DBiasExtendConv2DScaleExtendConv2DBiasScale,新增 round_modeenable_relu0nullptr_inputs_index 等属性,并支持 DT_INT8/DT_UINT64/DT_INT32 等低精度数据类型。

  • Conv2DAttr 结构体扩展与重构:在 common_utils.h 中将 Conv2DAttris_bias/is_offset_w 重命名为 has_bias/has_offset_w,新增 has_scale0is_extend_conv2dnullptr_inputs_indexround_modefixed_shift_valueenable_relu0 等字段,并新增 GET_EXTEND_CONV2D_ATTRS 宏用于解析扩展属性。

  • Codegen 内核调用槽位顺序固定与 scale0 支持:在 codegen_kernel.cpp 中,GenCubeTilingSingleFuncCall 新增 is_scale0 参数,Conv2D 系列调用槽位统一为 x, filter, bias(可选), offset_w(可选), scale0(可选),缺失的 optional 输入自动填入 nullptr;模板参数列表新增 BatchOneNoPadSmallWeightSmallKernel

  • Conv2D 内核模板重构conv_pingpong_basic_atcos.hConvActKernel 改为以 Conv2DTilingData 作为模板参数,移除 ConvShape/ConvDim 的运行期构造,新增 SCALE_TYPEscaleGM 参数,并新增 FmapTiling/WeightTiling/L1PingPong/L0PingPong/OutputOrder/IterOrder 模板参数;同时移除 CONV_A_FULL_LOAD_MODEA_FULL_LOAD_MODE 宏。

  • Python 编译流程适配 ExtendConv2Dasc_codegen_compile.pybuild_conv_args 重写为基于 nullptr_inputs_index 的 optional 输入处理逻辑,ascbc_conv_kernel_tiling_pro 新增 round_modeenable_relu0dual_outputdtype0/dtype1 等属性的提取与传递,dtype_map 扩展支持 int8/16/32/64 及 uint 类型,tiling 数据生成中增加 IS_ENABLE_SCALE0/DTYPE_SCALE0 等宏定义。

likedislike
不准确?
atomgit-bot
atomgit-bot
8月6日 评论:

代码审查

所有文件已审查完毕,现在给出总结。


审查总结

按优先级统计

  • P0: 1 个 — create_conv_tiling_data 中硬编码的 origin_inputs 索引导致 Conv2DOffset / ExtendConv2DScale 等场景 IndexError 崩溃
  • P1: 1 个 — TilingSetShapeDim 签名变更移除默认参数,破坏外部文件 codegen_tiling_inductor_topn.cpp编译
  • P2: 2 个 — 局部变量用作引用类型非类型模板实参(标准合规风险);GenAutofuseLaunchDeclare 缺少未知输入类型 fallback(声明-调用参数不匹配风险)
  • P3: 1 个 — 生产代码中遗留 print() 调试语句

各文件审查结果

文件 结果
autofuse/ascir/generator/ascir_builtin_ops_v1.cpp 无问题(REG_ASC_IR 注册正确,属性变更一致)
autofuse/codegen/codegen_kernel.cpp 无问题(conv2d 调用槽位顺序和模板参数传递正确)
autofuse/codegen/codegen_kernel.h 无问题(签名变更与 .cpp 一致)
autofuse/codegen/codegen_tiling.cpp 含 P2 问题(GenAutofuseLaunchDeclare 无 fallback);新增函数逻辑其他部分正确
autofuse/codegen/codegen_tiling.h 含 P1 问题(TilingSetShapeDim 签名破坏性变更)
autofuse/common/ascgraph_info_complete.cpp 无问题(kOpTypeToComputeType 映射添加正确)
autofuse/common/common_utils.cpp 无问题(新增 IsConv2DTypeWithScale0、ParseConv2DAttr 分支正确)
autofuse/common/common_utils.h 无问题(新常量/结构体字段/宏定义正确一致)
autofuse/compiler/py_module/pyascir_types.cpp 无问题(字段重命名 is→has、新属性透传一致)
autofuse/compiler/python/asc_codegen_compile.py 含 P0 问题(origin_inputs 索引越界)含 P3 问题(debug print)
autofuse/compiler/python/ascendc_compile.py 无问题(仅注释代码块添加,无害)
autofuse/graph_metadef/graph/ascendc_ir/core/asc_graph_ge_bridge.cc 无问题(MAKE_NODE 添加正确)
autofuse/v35/ascendc/api_cube/conv2d.h 含 P2 问题(局部变量引用模板实参)
autofuse/v35/ascendc/api_cube/conv2d/conv2d_v2_tilingkey_cv.h 无问题(新模板参数 BatchOne/NoPad/SmallWeight/SmallKernel 声明正确)
autofuse/v35/ascendc/api_cube/conv2d/conv_pingpong_basic_atcos.h 无问题(ConvActKernel 重构一致)
autofuse/v35/ascir/generator/ascir_builtin_ops_v2.cpp 无问题(与 v1 模式一致)
autofuse/v35/ascir/generator/v2_ascir_att_impl.h 无问题(REG_ASC_IR_ATT_V2_CLASS_DEFINE 添加正确)

整体风险评估

高风险。P0 问题(origin_inputs 索引越界)会导致 Conv2DOffset 及 ExtendConv2DScale 等场景在运行 create_conv_tiling_data 时直接 IndexError 崩溃,属于功能性阻断缺陷。P1 的 TilingSetShapeDim 签名变更会破坏外部编译。建议在合入前修复 P0 和 P1 问题。

类型 数量
🔴 阻塞 2
🟡 建议 1

⛔ 需要修改

likedislike
不准确?
CANN-robotCANN-robot成员
8月6日 添加了label:cann-cla/no
此处折叠了298条消息 查看更多
hemahemahemahema
18 天前 修改了pull request 的描述
Xxuyafei成员
17 天前 解决了最后一个问题
yangyongqiang
yangyongqiang成员
16 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
16 天前 添加了label:approved
CANN-robotCANN-robot成员
16 天前 合入了pull request