Pull Request已成功合入, 合并人@CANN-robot
(感谢 张伟伟 的贡献)变更摘要
本次 PR 对 relu6 算子进行规范化整改,重点对齐仓内标准的 dtype 分发机制并补全形状/类型推导实现。核心改动包括:新增 InferDataType 实现,使输出 dtype 直接继承输入 x 的 dtype;移除原先通过 TilingData.dataType 与 ASCENDC_TPL 模板参数进行 dtype 编码分发的机制,改为由 def 文件声明 DataType 列表、构建系统注入 DTYPE_X 宏的方式驱动 Kernel 类型;同时整理 InferShape 实现并同步更新相关 UT 用例,未涉及算法逻辑变更。
主要改动
- 新增
InferDataType实现: 新增relu6_graph_infer.cpp,注册InferDataTypeForRelu6,通过context->GetInputDataType(0)取输入 x 的 dtype 并设置到输出 y,复用 canndev 仓InferDtype4SameInput通用模式。 - dtype 分发机制对齐: 在
relu6.cpp中移除模板参数D_T,Kernel 直接使用DTYPE_X实例化NsRelu6::Relu6,并在relu6_tiling_key.h中删除ASCENDC_TPL_ARGS_DECL与ASCENDC_TPL_SEL的 dtype 模板声明。 - Tiling 侧移除 dataType:
relu6_tiling_arch35.cpp删除tiling->dataType赋值和ASCENDC_TPL_SEL_PARAM调用,relu6_tiling_data.h同步移除int32_t dataType字段,TilingData 不再存储 dtype。 InferShape规范化:relu6_infershape.cpp中将input_shape/output_shape重命名为inputShape/outputShape,保持输出形状复制输入形状的逻辑不变。- UT 用例同步调整:
test_relu6.cpp中 6 个测试用例移除tilingData->dataType赋值,与更新后的Relu6TilingData结构体保持一致。


Hi @zhangweiwei11, welcome to submitting your first PR to ops-nn!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
relu6 算子存在两类规范化问题:dtype 分发机制与仓内标准模式不一致、InferShape/InferDataType 实现不完整。本 PR 仅针对这两方面进行整改,不涉及算法逻辑变更。
关联的Issue
https://gitcode.com/cann/ops-nn/issues/4811
测试
文档更新
无。本次改动不涉及 README.md 或其他文档更新。
类型标签
AI/Agent生成声明