| refactor: fix mlir compile
Co-authored-by: huangchengnuo<huangchengnuo1@huawei.com>
# message auto-generated for no-merge-commit merge:
!30363 merge fix_mlir_compile into v2.7.1
refactor: fix mlir compile
Created-by: SorryNaCN
Commit-by: huangchengnuo
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->
# 【合入来源】
> (如有)请关联需求文档/issue链接
- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新
# 【修改方案】
1. 移除 Python 侧动态构建 MLIR 扩展与相关打包逻辑:清理 setup.py 中 pybind11 扩展、libcpp_common 编译及文件
拷贝路径。(setup.py)
2. MLIR 绑定下沉到 C++:新增 torch_npu._C.mlir 子模块,提供 load_kernel_binary 接口,替代原 `_inductor/
ascend_npu_ir/_C 绑定实现。(torch_npu/csrc/inductor/mlir/mlir_bindings.cpp`)
3. 统一 MLIR 运行时公共代码位置:hacl_rt.h/cpp_common 迁移到 torch_npu/csrc/inductor/mlir/,并补齐导出与
msprof 头文件引用。(torch_npu/csrc/inductor/mlir/cpp_common.{h,cpp})
4. 适配调用路径:mlir_compiler.py 使用 torch_npu._C.mlir.load_kernel_binary,同时删除 build_ext 初始化逻
辑。(torch_npu/_inductor/__init__.py、torch_npu/utils/_dynamo.py、`torch_npu/_inductor/
ascend_npu_ir/...`)
5. 更新测试与构建脚本:移除对 build_ext 的 public bindings 依赖,修正 CMake 源文件列表。(`test/npu/
test_public_bindings.py、torch_npu/csrc/inductor/CMakeLists.txt`)
# 【资料变更】
不涉及
# 【接口变更】
不涉及(内部绑定实现迁移,无跨仓/对外接口变更)
# 【功能验证】
- 未本地执行,待CI验证(如需可补自验证截图)
# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常
See merge request: Ascend/pytorch!30363 | 3 个月前 |