Pull Request已成功合入, 合并人@CANN-robot
(感谢 liulinxiang 的贡献)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/ops-math | ✅ wangrui_, songkai111 (2/2) | ✅ wangrui_, songkai111 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


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


问题/功能描述
本次PR主要优化了安装脚本中针对异构架构(如x86_64与aarch64)的共享库(.so文件)安装与卸载逻辑。解决了原有脚本在跨架构安装时权限处理不完善、代码冗余以及卸载时目录清理不彻底的问题,提升了脚本的健壮性和可维护性。
修改方案描述
本次修改通过代码重构,将分散、硬编码的逻辑抽象为统一的函数。具体包括:1)创建 handle_multi_arch_install 函数,统一处理目录创建、权限检查与恢复、文件拷贝,确保操作安全;2)创建 remove_so_and_empty_dir 函数,统一处理文件删除和空目录的递归清理,并具备相同的权限安全机制;3)修正了 GRAPH_SO_PATH 和 HOST_SO_PATH 的源文件路径前缀,确保路径引用准确。


scripts/package/ops_math/scripts/install.shGRAPH_SO_PATH="${CURR_PATH}/../../../../opp/built-in/op_graph/lib/linux/${ARCH_INFO}/libopgraph_math.so"恢复使用变量 ${OPP_PLATFORM_DIR},以确保路径配置的灵活性和一致性。修改为:GRAPH_SO_PATH="${CURR_PATH}/../../../../${OPP_PLATFORM_DIR}/built-in/op_graph/lib/linux/${ARCH_INFO}/libopgraph_math.so"此评论由代码审查工具自动生成


scripts/package/ops_math/scripts/install.shHOST_SO_PATH="${CURR_PATH}/../../../../opp/built-in/op_impl/ai_core/tbe/op_host/lib/linux/${ARCH_INFO}/libophost_math.so"恢复使用变量 ${OPP_PLATFORM_DIR}。修改为:HOST_SO_PATH="${CURR_PATH}/../../../../${OPP_PLATFORM_DIR}/built-in/op_impl/ai_core/tbe/op_host/lib/linux/${ARCH_INFO}/libophost_math.so"此评论由代码审查工具自动生成


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


compile


流水线任务触发成功
任务链接 [a3835caa4ef146eea6a0aa7807155133][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| anti_virus | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | |
| harmony-infer | ✅ SUCCESS | ||
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| Smoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-03-12 11:05:40] CI执行结束


问题: 重构后缺失对so文件设置可执行权限
原代码在异构安装时会执行 chmod 755 ${graph_so_dir_path}/* 来确保 .so 文件具有可执行权限。新的 handle_multi_arch_install 函数虽然成功重构了目录创建、权限处理和文件拷贝逻辑,但遗漏了对拷贝后 so 文件设置可执行权限的步骤。
建议: 在 cp -f "${so_file}" "${target_dir}" 后添加对拷贝文件的权限设置,例如:
chmod 755 "${target_dir}"/*
或针对特定文件:
chmod 755 "${target_dir}/$(basename "${so_file}")"


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


compile


流水线任务触发成功
任务链接 [8bd6ec64a1104dcfb4cabc5506ed86a8][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| anti_virus | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_A5 | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_A5_ubuntu24 | ✅ SUCCESS | >>>>> | |
| harmony-infer | ✅ SUCCESS | ||
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_experimental_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_ARM_A5_ubuntu24 | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS | ||
| UT_Test_kernel | ✅ SUCCESS | ||
| Smoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-03-12 16:23:33] CI执行结束


/approve


Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: songkai111, wangrui_.
Reviewers who wrote a comment of /lgtm are: wangrui_, songkai111.


The MR can not be merged, because of CodeReview discussion not resolved
If you want to solve this problem, you can click here to do it in the FAQs.


Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: songkai111, wangrui_.
Reviewers who wrote a comment of /lgtm are: songkai111, wangrui_.


描述
本 PR 重构了异构安装脚本的代码结构:
提取通用函数 `handle_multi_arch_install`
简化调用逻辑
修复权限处理问题
关联的Issue
https://gitcode.com/cann/ops-math/issues/911
测试
文档更新
无需更新文档
类型标签