当前Pull Request已关闭, 关闭人@zl_hw
变更摘要
本 PR 为 FusedMulAdd、FusedMulAddAdd、MulNoNan 三个算子补齐 InferDataType 注册:在各自的 op_host 侧新增 InferDataType4Xxx 函数,将输出 Y 的数据类型设置为与输入 x1(索引 0)一致,并通过 IMPL_OP_INFERSHAPE(X).InferShape(...).InferDataType(...) 完成注册,使其与 op_proto 中"输出 dtype 与 x1 相同"的定义对齐。同时为三个算子补充了对应的 InferDataType 单测用例,覆盖 fp16/fp32/int32(MulNoNan 另有 bf16)等场景,并顺带将测试用例的构造代码统一为单行格式。
主要改动
- 新增
InferDataType推导函数: 在fused_mul_add_infershape.cpp、fused_mul_add_add_infershape.cpp、mul_no_nan_infershape.cpp中分别新增InferDataType4FusedMulAdd、InferDataType4FusedMulAddAdd、InferDataType4MulNoNan,通过context->SetOutputDataType(...)将输出Y的 dtype 设置为输入x1的 dtype,并返回ge::GRAPH_SUCCESS。 - 扩展注册链: 三个算子的注册宏由
IMPL_OP_INFERSHAPE(X).InferShape(...)扩展为IMPL_OP_INFERSHAPE(X).InferShape(...).InferDataType(...),使注册的算子实现同时携带infer_datatype能力。 - 新增输入/输出索引常量: 各文件引入
FUSED_MUL_ADD_INPUT_X1_INDEX/FUSED_MUL_ADD_OUTPUT_Y_INDEX(及FusedMulAddAdd、MulNoNan对应常量)等constexpr索引,用于明确输入x1与输出Y的位置。 - 补充
InferDataType单测: 三个测试文件引入op_infer_datatype_context_builder.h与base/registry/op_impl_space_registry_v2.h,通过OpInferDataTypeContextBuilder构造上下文并断言输出 dtype 跟随输入x1(fp16/fp32/int32,MulNoNan另含 bf16)。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-math | ✅ 宋恺, 汤平川 (2/2) | ✅ 汤平川, 宋恺 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Guide
@zl_hw , thanks for your pull request.
The following commit(s) have not signed Contributor License Agreement (CLA).
| Commit | Reason |
|---|---|
| e8ed038d fix(op_host): FusedMulAdd/FusedM... | the email is not signed for CLA! please check if it is correct and the same as your signed email. |
If you need to sign CLA, you can click here to sign the CLA.
If you need to check if the email is set up correctly, you can click here to do it in the FAQs.
After signing the CLA or updating the email, you must comment /check-cla to check the CLA status again.


/approve


/lgtm
/approve


描述
问题
FusedMulAdd、FusedMulAddAdd、MulNoNan 这 3 个算子在
op_host/*_infershape.cpp中只注册了InferShape,没有注册InferDataType,GE 图通路上输出 dtype 缺少显式推导来源。方法
在各算子已有的
op_host/*_infershape.cpp中新增InferDataType4<OpType>,并将原有IMPL_OP_INFERSHAPE注册扩展为.InferShape(...).InferDataType(...)。三个算子的输出 dtype 均跟随 x1,与 op_proto 一致:关联的Issue
关联 Issue #2987
测试
bash build.sh -u --ophost --ops=fused_mul_add,fused_mul_add_add,mul_no_nan结果:47 tests PASSED,0 FAILED。其中包含本次新增的 10 条 infer_datatype 用例:
用例中的
ASSERT_NE(opImpl->infer_datatype, nullptr)实证该注册可被OpImplSpaceRegistryV2取到。门禁自检:clang-format 18.1.8
--style=file6 个文件全通过;仓内scripts/oat_check.sh6 个文件 All checks passed;trailing-whitespace / end-of-file / 冲突标记检查通过。关于 diff 体积:三个 UT 文件的存量代码为非 clang-format 风格,本次触碰后被 pre-commit 的 clang-format 整文件重排,故 diff 中含大量纯格式行(每个文件约 300 行增删,实质改动约 90 行)。三个实现文件无格式变更。
未覆盖:本次仅验证到 op_host UT 层(用例通过注册表取到
infer_datatype函数指针后直接调用),未做真机与 GE 图 e2e 验证。文档更新
无。本次仅新增 InferDataType 注册与对应 UT,不涉及对外接口与算子资料变更。
类型标签