Pull Request已成功合入, 合并人@CANN-robot
(感谢 why you 的贡献)变更摘要
此 PR 修复了 aclop 单算子编译与 GeSession 图编译混跑时自定义 Pass 资源被提前释放的问题。根因是 GeGenerator::Finalize() 直接调用 ShutdownPassPluginsForProcess() 执行进程级卸载,清空 registration_datas_ 并 dlclose 动态库,导致后续图编译中自定义 Pass 不再执行。解决方案核心是在 PassPluginLoader 中引入引用计数 active_users_,使 LoadPassPlugins() 和 UnloadPassPlugins() 成对调用时仅在所有使用者释放后才真正卸载资源,并将所有调用方从进程级 ShutdownPassPluginsForProcess() 统一迁移到引用计数式的 UnloadPassPlugins()。
主要改动
PassPluginLoader引入引用计数机制:Load()中仅在active_users_==0时首次加载 C++/Python Pass 并每次 +1,Unload()中每次 -1 且仅在active_users_==0时真正卸载资源并执行进程级清理,同时移除原来的ShutdownForProcess()和RollbackPythonPassesLoad()方法。- 所有调用方统一使用
UnloadPassPlugins():api/atc/main_impl.cc、api/session/client/ge_api_v2.cc、compiler/api/aclgrph/ge_ir_build.cc中的ShutdownPassPluginsForProcess()全部替换为UnloadPassPlugins(),头文件pass_plugin_loader.h中移除该函数声明。 GeGenerator增加 Pass 生命周期安全保障:新增pass_plugins_loaded_标志位配合GE_DISMISSABLE_GUARD,Initialize()成功加载 Pass 后设置标志并通过 guard 确保失败时自动Unload,Finalize()中仅在标志为真时调用UnloadPassPlugins()而非进程级 shutdown。CustomPassHelper并发安全修复:新增mutable std::shared_mutex mutex_成员,Load()和Unload()使用unique_lock,Run()使用shared_lock;Insert()去除锁以避免Load()持锁时dlopen触发PassReceiver构造函数回调 →Insert()重入导致同线程死锁。- 新增单元测试覆盖:
fusion_pass_executor_unittest.cc增加引用计数多引用/无引用场景和 Python Pass 加载卸载测试;ge_generator_unittest.cc增加Initialize失败时自动释放 Pass 插件的验证用例。


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/ge | ✅ Mexyy, kobemini, 张德鹏 (3/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
qq_45842700, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [42acb6ec3b094115bbd7c8f4c5087344][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_dflow | ✅ SUCCESS | ||
| UT_Test_ge_common | ✅ SUCCESS | ||
| UT_Test_parser | ✅ SUCCESS | ||
| UT_Test_python | ✅ SUCCESS | >>>>> | |
| UT_Test_rt | ✅ SUCCESS | ||
| UT_Test_acl | ✅ SUCCESS | ||
| UT_Test_autofuse | ✅ SUCCESS | ||
| UT_Test_executor | ✅ SUCCESS | ||
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_dflow | ✅ SUCCESS | ||
| ST_Test_ge_common | ✅ SUCCESS | ||
| ST_Test_parser | ✅ SUCCESS | ||
| ST_Test_python | ✅ SUCCESS | >>>>> | |
| ST_Test_rt | ✅ SUCCESS | ||
| ST_Test_autofuse | ✅ SUCCESS | ||
| ST_Test_executor | ✅ SUCCESS | ||
| ST_Test_hetero | ✅ SUCCESS | ||
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_autofuse_e2e | ✅ SUCCESS | ||
| UT_Test_fe | ✅ SUCCESS | ||
| UT_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_fe | ✅ SUCCESS | ||
| ST_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_ge_common_atc | ✅ SUCCESS | ||
| UT_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_fe | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_fe | ✅ SUCCESS | >>>>> |
[2026-08-03 16:41:24] CI执行结束


流水线任务触发成功
任务链接 [89025dd94f4045d989009eb790053e19][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_ARM_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-08-03 16:34:58] CI执行结束


流水线任务触发成功
任务链接 [e0c86251c51944ca86a515c564245732][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-08-03 16:33:15] CI执行结束


ShutdownPassPluginsForProcess删除之后 设计文档需要同步更新一下


流水线任务触发成功
任务链接 [2ba93cc3dcd041caaed0681488ff9401][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_ARM_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-08-03 21:09:53] CI执行结束


流水线任务触发成功
任务链接 [6cf763eed3374bb798655e92e9b94ab6][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_dflow | ✅ SUCCESS | ||
| UT_Test_ge_common | ✅ SUCCESS | ||
| UT_Test_parser | ✅ SUCCESS | ||
| UT_Test_python | ✅ SUCCESS | >>>>> | |
| UT_Test_rt | ✅ SUCCESS | ||
| UT_Test_acl | ✅ SUCCESS | ||
| UT_Test_autofuse | ✅ SUCCESS | ||
| UT_Test_executor | ✅ SUCCESS | ||
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_dflow | ✅ SUCCESS | ||
| ST_Test_ge_common | ✅ SUCCESS | ||
| ST_Test_parser | ✅ SUCCESS | ||
| ST_Test_python | ✅ SUCCESS | >>>>> | |
| ST_Test_rt | ✅ SUCCESS | ||
| ST_Test_autofuse | ✅ SUCCESS | ||
| ST_Test_executor | ✅ SUCCESS | ||
| ST_Test_hetero | ✅ SUCCESS | ||
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_autofuse_e2e | ✅ SUCCESS | ||
| UT_Test_fe | ✅ SUCCESS | ||
| UT_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_fe | ✅ SUCCESS | ||
| ST_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_ge_common_atc | ✅ SUCCESS | ||
| UT_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_fe | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_fe | ✅ SUCCESS | >>>>> |
[2026-08-03 21:16:27] CI执行结束


流水线任务触发成功
任务链接 [7b1b78e5ff514a78af8772a32411eccc][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-08-03 21:08:12] CI执行结束


/lgtm


描述
修复 aclop 单算子编译与 GeSession 图编译混跑时,自定义 Pass 资源被提前释放的问题。
问题根因:
GeGenerator::Finalize()调用ShutdownPassPluginsForProcess()执行进程级 Pass 卸载,清空registration_datas_并dlclose动态库句柄。aclop 单算子编译结束后会释放仍被 GeSession 图编译依赖的 Pass 资源,导致后续图编译中自定义 Pass 不再执行。解决方案:
PassPluginLoader引入引用计数active_users_:LoadPassPlugins():active_users_==0时首次加载 C++/Python Pass,每次调用 +1UnloadPassPlugins(): 每次调用 -1,仅active_users_==0时真正卸载 + 进程级清理GeGenerator::Finalize()改用UnloadPassPlugins()替代ShutdownPassPluginsForProcess(),只递减引用计数,不强制卸载进程级资源GeGenerator增加pass_plugins_loaded_flag +GE_DISMISSABLE_GUARD,保证 Initialize 失败时自动释放 Pass 引用GEInitialize/GEFinalize/GeGenerator/ATC/aclgrphBuild)统一用 Load/UnloadPassPluginLease类、AcquirePassPlugins/ReleasePassPlugins/ShutdownPassPluginsForProcessCustomPassHelper::Insert()去掉unique_lock,防止Load()持锁时dlopen触发PassReceiver构造函数 →Insert()重入导致同线程死锁(std::shared_mutex不支持递归)变更类型
核对清单