已关闭
[Bug-Report|缺陷反馈]: Relu6D dtype 未由 def 驱动且算子原型缺少重复定义宏保护 #4780
zhongheng创建于  8月13日关闭于  8月18日
zhongheng
8月13日 创建

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

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

ops-transfer-test-scan 检查发现以下问题:

  1. Relu6D 转测准入“def 驱动 dtype”不满足要求。

Relu6D 当前通过 tiling key 模板声明和分发 dtype,kernel 类型与 tiling key 绑定,没有完全由算子 def 生成的 DTYPE_X 驱动。这会导致 dtype 配置存在两套来源,增加配置不一致以及新增 dtype 时遗漏修改的风险。

  1. Relu6D 和 SmoothL1LossGrad 转测准入存在重复定义风险。

这两个算子的 REG_OP 定义可能同时来自算子目录、公共扩展头或 CANN legacy proto。相关定义缺少 OPS_PROTO_DEF_* 宏保护,在多份 proto 合并或共同包含时可能产生重复定义。

涉及文件主要包括:

  • activation/relu6_d/op_graph/relu6_d_proto.h
  • activation/relu6_d/op_host/arch35/relu6_d_tiling_arch35.cpp
  • activation/relu6_d/op_kernel/relu6_d.cpp
  • activation/relu6_d/op_kernel/arch35/relu6_d_tiling_key.h
  • common/inc/op_graph/op_nn_proto_extend.h
  • loss/smooth_l1_loss_grad/op_graph/smooth_l1_loss_grad_proto.h

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

目标硬件/SoC:

  • Ascend 950
  • 编译 SoC:Ascend950PR_9599

软件环境:

  • CANN 9.2.0
  • GNU C/C++ 9.4.0
  • Python 3.11.9
  • ops-nn master:e806bc311
  • 测试模式:Host UT、Kernel UT 模拟器及正式算子二进制编译

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

  1. 获取 ops-nn 仓库并切换到受影响版本。

  2. 使用 ops-transfer-test-scan 检查以下算子目录:

    • activation/relu6_d
    • loss/smooth_l1_loss_grad
  3. 检查 Relu6D 第 7 项,可以看到:

    • tiling key 中声明了 dtype 模板;
    • host tiling 根据输入 dtype 设置 tiling key;
    • kernel 入口通过 tiling key 模板参数选择数据类型;
    • dtype 未完全由 def 生成的 DTYPE_X 驱动。
  4. 检查第 1 项,可以看到:

    • Relu6D 的本地 REG_OP 定义与 CANN legacy proto 中定义同名;
    • SmoothL1LossGrad 在算子目录和公共扩展头中均存在 REG_OP 定义;
    • 对应定义没有统一的 OPS_PROTO_DEF_* 宏保护。
  5. 合并或共同编译相关 proto 定义时,存在同名算子原型被重复展开的风险。

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

  1. Relu6D 的 kernel dtype 应完全由算子 def 生成的 DTYPE_X 驱动:

    • tiling key 不再承载 dtype 模板参数;
    • host tiling 使用固定 tiling key;
    • kernel 入口直接实例化 KernelRelu6D<DTYPE_X>;
    • def 中配置的 FP16、FP32、INT32、BF16 均可正确生成和编译。
  2. Relu6D 和 SmoothL1LossGrad 的 REG_OP 定义应增加统一宏保护:

    • Relu6D 使用 OPS_PROTO_DEF_RELU6D;
    • SmoothL1LossGrad 使用 OPS_PROTO_DEF_SMOOTHL1LOSSGRAD;
    • 多份 proto 合并或共同包含时,同名算子只定义一次。

修复后验证结果:

  1. Relu6D Host/Proto UT

    • 运行 24 个测试
    • 24/24 通过
  2. Relu6D Kernel UT

    • FP32 small:通过
    • FP16 small:通过
    • INT32 small:通过
    • BF16 small:通过
    • FP32 multi-loop:通过
    • 共 5/5 通过,输入和 golden 数据均成功生成
  3. Proto 合并编译

    • Relu6D 本地 proto
    • SmoothL1LossGrad 本地 proto
    • common/inc/op_graph/op_nn_proto_extend.h
      以上定义合并并编译成功,未出现重复定义错误。
  4. Relu6D 正式二进制编译

    • float16:成功
    • float32:成功
    • int32:成功
    • bfloat16:成功

编译最终输出:
[SUCCESS] Build binary success!

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

重复定义问题按照 PR 8552 的处理方式修复,即保留现有 REG_OP 定义并增加 OPS_PROTO_DEF_* 宏保护,不删除重复定义代码。

likedislike
Zzhongheng
8月13日 修改了issue 的描述
Zzhongheng
8月13日 关联了pull request:修复 Relu6D def 驱动 dtype 及算子原型重复定义问题
yuning_chenyuning_chen成员
8月13日 将 zhongheng 设为负责人
CANN-robotCANN-robot成员
8月18日 关闭了 issue
CANN-robotCANN-robot成员
8月18日 添加了label:resolved