Pull Request已成功合入, 合并人@CANN-robot
(感谢 小王! 的贡献)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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| pooling | ✅ chenqi317, fanqirui (2/2) | ✅ chenqi317 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
qq_52056150, thanks for your pull request. All authors of the commits have signed the CLA. 👍


🔵 source code change are detected, tasks labels is removed in this pull request!


compile


流水线任务触发成功
任务链接 [d8d3e5389a7f40eeb14d225f6fe856fc][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 解析CI分支 | ✅ SUCCESS | ||
| codecheck | ✅ SUCCESS | >>>>> | |
| anti_virus | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_950 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_950 | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| Pre_Compile | ✅ SUCCESS | ||
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_950_ubuntu24 | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS | ||
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_950_ubuntu24 | ✅ SUCCESS | >>>>> | |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| UT_Test_opgraph | ✅ SUCCESS | ||
| Smoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-03-18 16:09:52] CI执行结束


问题/功能描述
本次PR主要对多个池化算子(包括AdaptiveMaxPool3d、AvgPoolV2Grad、MaxPoolGradWithArgmaxV3、MaxPoolWithArgmaxV3等)的Tiling(分片)及Shape推理相关代码进行了重构、优化和缺陷修复。核心目标是提升代码的类型安全性、修复逻辑错误、统一编码规范,并增强可维护性。具体解决了AvgPoolV2Grad算子中padding_mode属性验证逻辑错误的问题,并统一了多个文件中不安全的类型转换和命名空间使用方式。
修改方案描述
修改方案主要包括四个方面:1) 修复逻辑缺陷:修正了avg_pool_v2_grad_infershape.cpp中padding_mode属性的验证逻辑,确保能正确识别非法模式。2) 提升类型安全:在多个文件中,将指针类型转换从不安全的reinterpret_cast统一改为更安全的static_cast,以明确转换意图并减少未定义行为风险。3) 优化代码结构与风格:将多个头文件中的using namespace声明移入namespace optiling内部,避免全局命名空间污染;将部分静态工具函数声明为static inline以优化编译;调整构造函数初始化列表以遵循最佳实践。4) 清理冗余代码:删除不必要的空行。这些修改不改变算子核心功能,属于代码质量优化和维护性工作。


pooling/avg_pool_v2_grad/op_host/avg_pool_v2_grad_infershape.cppOP_CHECK_IF(strcmp(padding_mode, "SAME") != 0 && strcmp(padding_mode, "VALID") != 0 &&
strcmp(padding_mode, "CALCULATED") != 0, OP_LOGE(context->GetNodeName(),
"attr padding_mode(%s) only support SAME, VALID and CALCULATED", padding_mode),
return GRAPH_FAILED);将逻辑运算符 '&&' 改为 '||'。正确的逻辑是:如果 padding_mode 不等于 "SAME" 且不等于 "VALID" 且不等于 "CALCULATED",则报错。修改为:OP_CHECK_IF(strcmp(padding_mode, "SAME") != 0 || strcmp(padding_mode, "VALID") != 0 || strcmp(padding_mode, "CALCULATED") != 0, ...)。或者更清晰地写为:if (strcmp(padding_mode, "SAME") != 0 && strcmp(padding_mode, "VALID") != 0 && strcmp(padding_mode, "CALCULATED") != 0) { 报错 }。此评论由代码审查工具自动生成


/lgtm
/approve


描述
按照cleancode规范消除池化类算子的告警,包括但不限于如下告警点:
头文件中禁止向全局命名空间中导入符号;
避免使用reinterpret_cast;
遵循单一定义原则;
对于不会修改成员变量的成员函数应使用const修饰;
使用恰当的基本类型作为操作符的操作数;
禁止函数有未被使用的参数
关联的Issue
#1563
测试
本地自验证已通过
文档更新
不涉及
类型标签