Pull Request已成功合入, 合并人@CANN-robot
(感谢 likun104 的贡献)变更摘要
此 PR 主要对 GE 仓进行 clean code 告警清理,同时引入了 StridedSliceV3 算子的 lowering 支持、扩展了 OpRegistry 以支持按框架类型查找子图后处理函数,以及增加了自定义算子跳过 op_kernel_info 构建的逻辑。整体变更涵盖头文件清理、参数命名规范化、注释代码移除等代码卫生优化。
主要改动
-
新增
StridedSliceV3算子 lowering 支持: 在lowering_impl.cpp中新增LowerStridedSliceV3和ParseV3IndexInputs函数,实现 V3 版本 StridedSlice 的 lowering,支持符号 shape 推导、axes 扩充及 strides 默认值处理,并在autofuse_utils中新增GetSymbolicOrConstFallback辅助方法。 -
OpRegistry接口扩展,增加框架类型重载: 新增了两个带domi::FrameworkType参数的GetParseSubgraphPostFunc重载方法,在注册时将om_optype_与fmk_type_组合为复合键存储,避免不同框架的同名算子互相覆盖;onnx_parser.cc和tensorflow_parser.cc中的调用点同步切换至新接口。 -
自定义算子跳过 op_kernel_info 构建: 在
sub_op_info_store.cc的ConstructOpKernelInfo中增加ge::CustomOpFactory::IsExistOp判断,对已注册的自定义算子跳过 kernel info 构造,避免不必要的处理。 -
清理未使用的头文件引用及注释代码: 移除了多个文件中无用的
#include(如rt_external_mem.h、ge_common_api_types.h、aprof_pub.h、graph/node.h等共约 20 处),并删除了asc_backend_scheduler_adapter.cpp中的注释掉代码块和attr_serializer.h中的多余引用。 -
参数命名与代码风格规范化:
flow_func_manager.cpp中RegisterMultiFunc的参数名从下划线风格改为驼峰风格(如flow_func_name→flowFuncName);aipp_param_check.h中socVersion更名为npuArch;overload_planner.cc中const MultiBaselineMode mode移除冗余的const修饰。


代码审查
I've completed my review. Let me write the closing summary.
审查总结
已审查的全部 39 个文件:
| 文件 | 结论 |
|---|---|
api/acl/acl_model/model/aipp_param_check.h |
参数名变更 socVersion→npuArch,无问题 |
api/acl/utils/acl_attr_utils.h |
移除未使用头文件,无问题 |
api/session/session/inner_session.cc |
移除未使用 #include "rt_external_mem.h",无问题 |
base/common/dump/exception_dumper.h |
移除未使用 #include "rt_external_mem.h",无问题 |
base/common/helper/custom_op_registry_builder.h |
移除未使用头文件,无问题 |
blacklist.txt |
更新黑名单,无问题 |
compiler/engines/nn_engine/opskernel/ops_store/sub_op_info_store.cc |
新增 custom_op 跳过逻辑+include,无问题 |
compiler/graph/eager_style_graph_builder/es_generator/history/overload_planner.cc |
移除 const 限定符,无问题 |
compiler/graph/fusion/pass/fusion_pass_executor.cc |
移除未使用 #include,无问题 |
compiler/graph/optimize/autofuse/autofuse/can_fuse/strategy/fusion_strategy.h |
移除未使用头文件,无问题 |
compiler/graph/optimize/autofuse/autofuse/lowering/op_helper/stridedslice.cpp |
新增 begin_mask==0 早期返回,无问题 |
compiler/graph/optimize/autofuse/autofuse/lowering/op_lowering_impl/lowering_impl.cpp |
2 个问题:ParseV3IndexInputs 空 begin_expr_list 未返回错误(P2)、轴越界静默忽略(P3) |
compiler/graph/optimize/autofuse/autofuse/post_process/scheduler_adapter/asc_backend_scheduler_adapter.cpp |
删除注释代码,无问题 |
compiler/graph/optimize/autofuse/autofuse/utils/autofuse_utils.cpp |
4 个 P1 空指针解引用问题 |
compiler/graph/optimize/autofuse/autofuse/utils/autofuse_utils.h |
新增方法声明,无问题 |
compiler/graph/optimize/autofuse/graph/ascendc_ir/.../attr_serializer.h |
移除未使用 #include,无问题 |
compiler/graph/optimize/mem_layout_conflict_optimize/mem_layout_conflict_util.cc |
lambda 捕获优化,无问题 |
compiler/graph/optimize/symbolic/.../symbolic_shape_inference.h |
移除未使用 #include,无问题 |
compiler/graph/passes/base_pass.cc |
移除未使用 #include,无问题 |
compiler/graph/passes/pass_manager.cc |
移除未使用 #include,无问题 |
compiler/graph/passes/standard_optimize/tensor_move_delete_pass.h |
移除未使用 #include,无问题 |
compiler/graph/preprocess/insert_op/base_insert_op.h |
移除未使用 #include,无问题 |
dflow/udf/flow_func/flow_func_manager.cpp |
参数命名风格变更(仅 .cpp),无问题 |
graph_metadef/register/register.cpp |
1 个 P2:旧 GetParseSubgraphPostFunc 接口因 key 变更可能失效 |
inc/graph_metadef/register/op_registry.h |
新增重载声明,无问题 |
parser/parser/onnx/onnx_parser.cc |
更新为框架感知接口调用,无问题 |
parser/parser/tensorflow/tensorflow_parser.cc |
更新为框架感知接口调用,无问题 |
runtime/om2/om2_var_manager.cc |
修复 include 路径,无问题 |
runtime/v1/common/dump/data_dumper.h |
移除未使用 #include,无问题 |
runtime/v1/common/profiling/profiling_init.h |
移除未使用 #include,无问题 |
runtime/v1/graph/load/graph_loader.h |
移除未使用 #include,无问题 |
runtime/v1/graph/load/model_manager/model_args_manager.h |
移除未使用 #include,无问题 |
runtime/v2/api/api.cc |
移除未使用 #include,无问题 |
runtime/v2/engine/custom/kernel/custom_op_kernel.cc |
移除未使用 #include,无问题 |
scripts/package/ge-compiler/scripts/ge-compiler_custom_install.sh |
权限调整,无问题 |
tests/autofuse/ut/autofuse/test_lowering_and_canfuse.cpp |
新增测试+SplitV shape 修复,无问题 |
tests/engines/nn_engine/st/.../ops_kernel_info_store_stest_2.cc |
新增测试,无问题 |
tests/engines/nn_engine/ut/.../ut_ops_kernel_manager.cc |
新增测试,无问题 |
tests/graph_metadef/ut/register/testcase/register_unittest.cc |
测试更新匹配新接口,无问题 |
问题统计
- P0: 0
- P1: 4(
GetSymbolicOrConstFallback中 4 处空指针解引用) - P2: 2(
ParseV3IndexInputs空 begin_expr_list 未返回错误;旧GetParseSubgraphPostFunc接口兼容性) - P3: 1(
ParseV3IndexInputs轴越界静默忽略)
整体风险评估
中等风险。新增的 StridedSliceV3 lowering 功能在非符号编译场景下存在空指针崩溃风险(GetSymbolicOrConstFallback 中 GE_WARN_ASSERT 不终止执行导致连续空指针解引用),以及 ParseV3IndexInputs 在获取 begin 失败时返回成功但携带空数据。这些缺陷在特定输入条件下可导致进程崩溃,建议在上线前修复。其余大部分变更为无风险的代码清理(移除未使用头文件、删除注释代码等)。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 5 |
| 🟡 建议 | 3 |
⛔ 需要修改


Pull Request
描述
清理ge仓中的clean code告警
变更类型
请选择本次引入的变更类型:
关联的Issue
如何测试
描述测试此变更的步骤和前提条件:
核对清单
其他信息
在此添加任何其他关于本次 PR 的说明。