Pull Request has been successfully merged by CANN-robot.
(Thank you for huangbolin's contribution.)变更摘要
本 PR 修复 JIT 编译时 include 路径顺序问题:torch_npu 自带的 third_party/acl 版本较旧,与新版 CANN 头文件共用同名 include guard,若在 -I 搜索顺序中排在前面,会导致环境上实际安装的 CANN 头文件(含 ACL_FLOAT8_E5M2、ACL_FLOAT4_E2M1 等新 dtype 枚举)被抑制而编译报错。改动通过让 CANN 路径优先于 torch_npu 路径,并与 aclnn_common.h 的 include 顺序调整互相配合,确保新枚举可见。
主要改动
- 调整
OpBuilder.include_paths()的搜索顺序:将os.path.join(self._cann_path, "include")与include/aclnnop前移到torch_npu各路径之前,保证编译期-I顺序先命中环境上安装的 CANN 头文件;vendor的op_api/include仍保持最优先,以覆盖 CANN 同名 aclnn 头。 - 简化
get_cann_path()取值逻辑:由先判断ASCEND_HOME_PATH in os.environ再读取环境变量,改为通过os.environ.get取值并校验路径存在,无法获取时仍回退到torch_npu所在目录的上级。 - 补充
aclnn_common.h的注释说明:明确该文件仅调整 include 顺序属必要条件之一,<acl/acl_base.h>能否解析到实际安装的 CANN 头文件还取决于-I搜索顺序,需与OpBuilder.include_paths()的改动共同生效。 - 整理
builder.py的导入风格:将torch、torch.library.Library、torch.utils.cpp_extension.load的 import 重新分组排序,无行为影响。


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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| 9.2.0 | ✅ hanxiaolong, 蒋礼锐 (2/2) | ✅ hanxiaolong (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
hblnb, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve
/lgtm


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
/approve: 蒋礼锐


描述
fix: JIT编译include路径CANN优先于torch_npu修复新dtype枚举不可见报错
关联的Issue
https://gitcode.com/cann/ops-transformer/issues/5221
测试
文档更新
类型标签