已关闭
[Bug-Report|缺陷反馈]: relu6 算子 dtype 分发机制不是由def驱动,且缺少 InferDataType 图模式推理实现。 #4811
张伟伟创建于  18 天前关闭于  14 天前
张伟伟
18 天前 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

relu6 算子 dtype 分发机制与仓内标准模式不一致,且缺少 InferDataType 图模式推理实现。
具体问题:

  1. dtype 分发方式不规范:relu6 当前使用 ASCENDC_TPL(TilingKey 编码 dtype)方式做多 dtype 分发,需要维护 TilingKey 声明、dataType 字段、ASCENDC_TPL_SEL_PARAM 调用等一整套机制。而仓内既有算子(如 celu_v2、threshold、swiglu_group_quant)已统一采用 def 文件驱动的 DTYPE_X 宏方式,构建系统根据 def 文件的 DataType 列表自动注入宏,Kernel 直接使用 DTYPE_X 获取类型,无需 TilingKey 编码 dtype。两套机制并存导致代码风格不统一,维护成本高。
  2. InferShape 规范化缺失:relu6_infershape.cpp 缺少 CANNBot 标记和 doxygen 文件注释,变量命名使用 snake_case(input_shape、output_shape),与仓内 camelCase 规范不一致。
  3. InferDataType 未实现:relu6 缺少 op_graph/relu6_graph_infer.cpp,未注册 IMPL_OP(Relu6).InferDataType(...),图模式下无法推理输出 dtype。仓内同类算子(如 celu_v2、hard_sigmoid)均已补全此实现。

Environment / 环境信息 (Mandatory / 必填)

  • 仓库:ops-nn
  • 算子:activation/relu6
  • 目标芯片:Ascend950(arch35)
  • cann环境:cann-9.2.0
  • 参考算子:celu_v2(def 驱动 dtype + InferDataType 标准实现)

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. 查看 activation/relu6/op_kernel/arch35/relu6_tiling_key.h,可见 ASCENDC_TPL_ARGS_DECL / ASCENDC_TPL_SEL 声明,dtype 通过 TilingKey 编码分发
  2. 查看 activation/relu6/op_kernel/arch35/relu6_tiling_data.h,可见 int32_t dataType 字段,TilingData 中冗余存储 dtype
  3. 查看 activation/relu6/op_host/arch35/relu6_tiling_arch35.cpp,可见 tiling->dataType = static_cast<int32_t>(dataType) 和 ASCENDC_TPL_SEL_PARAM(context, dType) 调用
  4. 查看 activation/relu6/op_kernel/relu6.cpp,可见 template 模板参数入口
  5. 查看 activation/relu6/op_host/relu6_infershape.cpp,缺少 CANNBot 标记、doxygen 注释,变量名为 snake_case
  6. 查看 activation/relu6/op_graph/ 目录,不存在 relu6_graph_infer.cpp,未注册 InferDataType
  7. 对比仓内 celu_v2 算子,以上 1-6 点均与标准模式不一致

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  1. def 驱动 dtype:移除 ASCENDC_TPL 相关声明和 dataType 字段,Kernel 入口改用 DTYPE_X 宏,TilingData/TilingKey/Kernel/UT 五处一致联动,与 celu_v2 等算子对齐
  2. InferShape 整改:补充 CANNBot 标记和 doxygen 注释,变量名统一为 camelCase
  3. InferDataType 补全:新增 op_graph/relu6_graph_infer.cpp,注册 IMPL_OP(Relu6).InferDataType(...),实现 output dtype = input x dtype

Special notes for this issue/备注 (Optional / 选填)

likedislike
张伟伟
18 天前 评论:

/assign

likedislike
CANN-robotCANN-robot成员
18 天前 将 zhangweiwei11 设为负责人
张伟伟
18 天前 关联了pull request:relu6 算子 dtype 分发机制与仓内标准模式对齐,补全 InferShape/InferDataType 规范化实现。
CANN-robotCANN-robot成员
14 天前 关闭了 issue
CANN-robotCANN-robot成员
14 天前 添加了label:resolved