Pull Request已成功合入, 合并人@CANN-robot
(感谢 zhanj 的贡献)变更摘要
本次 PR 是一个从 develop 到 master 的同步合并,主要引入了一个 is_default_enabled 平台属性机制,用于标识平台是否为默认启用状态。改动涉及 BasePlatform/PlatformV1/PlatformV2 的构造函数与配置结构体、BackendSpec 和 AutofuseBackendSpec 的数据结构、平台注册宏的重构、GetPlatformConfig() 方法从子类提升到基类,以及脚本权限和文案的修正。同时新增了覆盖多平台、多个测试套件的相关单元测试和系统测试。
主要改动
- 新增
is_default_enabled字段贯通整个平台配置链:在PlatformConfig、BackendSpec和AutofuseBackendSpec中均增加了bool is_default_enabled字段,并由PlatformV1/PlatformV2的构造函数接收该参数,分别传递至三个层级,使上层 API(如GetAutofuseBackendSpec())也能获取平台默认启用状态。 - 平台注册机制重构:
PlatformCreator类型从原始函数指针改为std::function<std::unique_ptr<BasePlatform>()>,PlatformRegistrar构造函数新增is_default_enabled参数并转发给平台构造函数;注册宏REGISTER_PLATFORM_V1/REGISTER_PLATFORM_V2同步增加该参数,最终将2201和5102设为默认不启用、3510设为默认启用。 GetPlatformConfig()从子类上移至BasePlatform基类:BasePlatform新增protected成员PlatformConfig config_,GetPlatformConfig()由纯虚函数改为基类实现的非虚函数直接返回config_,移除了PlatformV1和PlatformV2中的重复实现与私有成员。BackendSpec::GetInstance()容错行为调整:当PlatformFactory::GetPlatform()返回nullptr时,由原来的GE_ASSERT_NOTNULL(中止)改为直接返回nullptr;同时PlatformFactory::GetPlatform()在找不到平台时将GELOGE降级为GELOGW,避免误报严重错误。- 安装脚本权限与文案修正:
__pycache__目录权限从550改为555(去除属主写权限),安装日志中修正了拼写错误(faied→failed、te→graph_autofusion)。


代码审查
以下是审查总结。
审查总结
我逐一审查了所有 19 个变更文件,以下是结果:
- autofuse/common/autofuse_backend_spec_api.cpp:在
GetAutofuseBackendSpec()中新增is_default_enabled字段的赋值,与现有模式一致,无问题。 - autofuse/common/autofuse_backend_spec_api.h:在
AutofuseBackendSpec中新增bool is_default_enabled = false;,提供了默认值,正确。 - autofuse/inc/backend/backend_spec.h:新增
bool is_default_enabled;字段,缺少默认初始化值(已报告为 P3 建议)。虽然遵循了该结构体的现有模式且所有构造函数路径都会设置该字段,但作为新增字段应当采用更佳实践。 - autofuse/optimize/platform/backend_spec.cpp:将
GE_ASSERT_NOTNULL(platform)替换为nullptr检查并返回。已验证所有调用方(codegen_tiling.cpp、codegen_kernel.cpp、concat_group_partitioner.cpp、concat_schedule_case_generator.cpp、schedule_case_generator.h)均通过显式的nullptr检查或GE_ASSERT_NOTNULL妥善处理,无破坏性变更。 - autofuse/optimize/platform/base_platform.h:将
GetPlatformConfig()从纯虚函数提升为基类实现,并将config_移至protected区域。PlatformV1和PlatformV2均已移除重复代码,重构合理。 - autofuse/optimize/platform/platform_factory.cpp:将
GELOGE改为GELOGW,降低了未知平台的日志严重等级。返回值(nullptr)保持不变,调用方均处理 null 路径,影响有限。 - autofuse/optimize/platform/platform_factory.h:
PlatformCreator从函数指针改为std::function;PlatformRegistrar新增is_default_enabled参数,一致性良好。 - autofuse/optimize/platform/v1/platformv1.cpp:构造函数新增
is_default_enabled参数;GetBackendSpec()设置is_default_enabled;移除了重复的GetPlatformConfig();REGISTER_PLATFORM_V1宏新增参数,所有注册均已更新。无问题。 - autofuse/optimize/platform/v1/platformv1.h:移除了重复的
GetPlatformConfig()声明和config_成员,与基类重构一致。无问题。 - autofuse/tests/st/optimize/CMakeLists.txt:新增
autofuse_backend_spec_api.cpp源文件;文件末尾补全换行符。无问题。 - autofuse/tests/st/optimize/optimize_st.cpp:新增
platform_config_test(第 3642 行)、BackendSpec中新增断言(第 4085 行)、新增AutofuseBackendSpecTest(第 4088 行)。测试逻辑正确,对GetPlatform()的nullptr返回路径有适当检查。 - autofuse/tests/ut/optimize/CMakeLists.txt:新增
autofuse_backend_spec_api.cpp源文件。无问题。 - autofuse/tests/ut/optimize/test_optimizer.cpp:新增
platform_config_test(第 7220 行)、BackendSpec中新增断言(第 7255 行)、新增AutofuseBackendSpecTest(第 7258 行)。SetUp()调用Reset()可防止测试间平台状态残留。无问题。 - autofuse/tests/v35/st/optimize/optimize_st_v2.cpp:新增
platform_config_test(第 112 行)、BackendSpec中新增断言(第 1110 行)、新增AutofuseBackendSpecTest(第 1113 行)。SetUp()调用Reset()。无问题。 - autofuse/tests/v35/ut/optimize/test_optimizer_v2.cpp:新增
platform_config_test(第 107 行)、BackendSpec中新增断言(第 3201 行)、新增AutofuseBackendSpecTest(第 3204 行)。SetUp()调用Reset()。无问题。 - autofuse/v35/optimize/platformv2.cpp:构造函数新增
is_default_enabled参数;GetBackendSpec()设置is_default_enabled;移除了重复的GetPlatformConfig();两个注册宏均已更新正确值("3510" 为true,"5102" 为false)。无问题。 - autofuse/v35/optimize/platformv2.h:移除了重复的
GetPlatformConfig()声明和config_成员。无问题。 - scripts/package/graph_autofusion/rpm_deb/custom_postinst.sh:
chmod 550→chmod 555。无问题。 - scripts/package/graph_autofusion/scripts/graph_autofusion_custom_install.sh:修复拼写错误("faied" → "failed","te" → "graph_autofusion");
chmod 550→chmod 555。无问题。
问题统计:P0: 0、P1: 0、P2: 0、P3: 1
整体风险评估:低。 该 diff 引入了一个新的 is_default_enabled 配置标志,贯穿平台配置、后端规格及对外 API 等各层,并配有全面的测试覆盖。一个结构体字段缺少默认初始化值(遵循现有模式),仅为轻微风格问题。将 BackendSpec::GetInstance() 从崩溃改为返回 nullptr 的变更,所有调用方均已妥善处理。无逻辑、安全或可靠性回归。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 2 |
💬 仅评论


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 |
|---|---|---|
| repo-cann/graph-autofusion | ✅ yangyongqiang0606, 盛楠, wangxiaotian995 (3/2) | ✅ yangyongqiang0606 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhanj, thanks for your pull request. All authors of the commits have signed the CLA. 👍


🟡 Medium Priority
与 custom_postinst.sh:61 相同的问题:chmod -R 550 改为 chmod -R 555,使 __pycache__ 目录及其中 .pyc 字节码文件对 "other" 用户变为可读可执行。安装脚本中对源码目录的权限管理(chmod_recur 使用 750/550)限制 other 用户访问,但此变更使编译后的字节码绕过该限制。
建议:与 custom_postinst.sh 的建议相同:将权限改回 550 以保持与源码目录权限策略一致。


🟡 Medium Priority
两个 shell 脚本中对 __pycache__ 目录的权限从 550(r-xr-x---,仅 owner 和 group 可读/可执行)改为 555(r-xr-xr-x,所有用户可读/可执行)。
__pycache__ 目录包含 Python 编译后的 .pyc 字节码文件,可以通过反编译工具还原出近似源码。而同一安装脚本中对 Python 源码目录的权限控制为 750(chmod_recur "${sourcedir}/python" 750 dir),即仅 owner+group 可访问。此变更使 .pyc 字节码的访问权限比源码目录更宽松,在多用户系统中,未授权的 "other" 用户可读取并反编译这些字节码,从而绕过源码目录的权限限制。
影响范围:custom_postinst.sh 第 61 行(rpm/deb 安装后脚本)和 graph_autofusion_custom_install.sh 第 372 行(自定义安装脚本)。
建议:建议保持与源码目录一致的权限策略。若 __pycache__ 需要可执行权限以支持 Python import 机制,可将权限设为 550(owner+group 可读可执行,other 无权限),与源码目录的权限模型一致。若确实需要放宽权限,请确认无安全风险并添加注释说明原因。


/compile


流水线任务触发成功
任务链接 [12221f7e2fbd4843bc83258766f9b12f][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-07-09 11:51:47] CI执行结束


流水线任务触发成功
任务链接 [82346ca07a2841d3b04727fb68ef03de][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| UT_Test_Python_superkernel | ✅ SUCCESS | >>>>> | |
| ST_Test_Python_superkernel | ✅ SUCCESS | >>>>> | |
| UT_Test_superkernel | ✅ SUCCESS | >>>>> | |
| UT_Test_autofuse_framework | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_framework | ✅ SUCCESS | >>>>> | |
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | >>>>> | |
| ST_Test_autofuse_e2e | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> |
[2026-07-09 12:22:03] CI执行结束


流水线任务触发成功
任务链接 [9e6d0687748e4d1d96d8943fd9c1e789][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck_checkpr | ✅ SUCCESS | ||
| pre_comment | ✅ SUCCESS | >>>>> | |
| codecheck_codestyle | ⚠️ WARNING | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> |
[2026-07-09 11:48:24] CI执行结束


/lgtm


/approve


Pull Request
描述
【PR】feat: sync develop to master 20260708
变更类型
请选择本次引入的变更类型:
关联的Issue
如何测试
描述测试此变更的步骤和前提条件:
1.
2.
核对清单
其他信息
在此添加任何其他关于本次 PR 的说明。