已合并
feat: 支持 Python 自定义算子原型与实现桥接注册 #4320
lfz2812创建于 11 天前
feat: 支持 Python 自定义算子原型与实现桥接注册 #4320
已合并
lfz2812创建于 11 天前
lfz2812成员
11 天前

Pull Request

描述

支持 Python 自定义算子原型从 Python descriptor 到 GE OperatorFactory 的注册,并完善 Python 自定义算子实现的 bridge 注册、校验和生命周期管理。

主要变更:

  • 根据 Python 函数签名收集输入、属性、输出及 mutates_args,生成并深拷贝 Python custom op proto。
  • 将 Python proto 注册为 OperatorFactory creator,并通过公开 IR 查询接口获取 canonical IR。
  • 按 proto 注册、canonical IR 收集、impl 签名校验、Adapter 注册的顺序完成加载。
  • 支持 proto-only、proto + Python impl、C++ proto + Python impl 以及 legacy impl。
  • 完善 Adapter descriptor、runtime registry 和 holder 的所有权管理。
  • 支持重复加载幂等、runtime lease pending cleanup 和注册失败回滚。
  • 增加 Python proto、descriptor、bridge loader、Adapter 以及 ST/UT 覆盖。
  • 当前阶段不执行 Python infer_meta,暂不覆盖编译期 Meta 推导和 RT2 runtime infer。
  • 同步更新中英文 Python custom op 设计文档。

变更类型

请选择本次引入的变更类型:

关联的Issue

#299

如何测试

本次补充和扩展以下测试:

  1. Python UT:

    • proto/impl descriptor 快照和关联关系。
    • proto-only、proto + schema-bound impl、C++ proto + Python impl 和 legacy impl 场景。
    • canonical IR 与 execute 签名校验。
    • schema-bound 输入和属性绑定、执行上下文作用域及失效检查。
    • plugin 和 bridge/native artifact 加载检查。
  2. C++ UT:

    • proto C POD view 解析和 owning 数据转换。
    • 支持的属性类型及默认值转换。
    • Operator creator 注册、冲突保护和卸载。
    • Adapter capability、runtime entry、holder 和 callback 生命周期。
    • loader 注册事务、失败回滚、幂等加载及 pending cleanup。
  3. ST:

    • Python proto 和 impl 注册、创建及卸载。
    • Python 自定义算子文件加载失败。
    • 不可访问的非 Python自定义算子路径跳过处理。

建议执行:

bash tests/run_test.sh --ut=python
cmake --build build_ut --target ut_libge_multiparts_utest -j4
ctest --test-dir build_ut -R ut_libge_multiparts_utest --output-on-failure
git diff --check

核对清单

其他信息

  • 本次完成 Python 原型到 C++ OperatorFactory 的注册,以及 Python 实现到 CustomOpFactory 的 Adapter 注册。
  • 本次不执行 Python infer_meta,不包含 infer callback、编译期 shape/data type 回写或 RT2 runtime infer 链路;这些内容由后续 PR 完成。
  • 本次保持 schema-bound execute 和迁移期 legacy execute(ctx) 的现有行为。
  • Bridge ABI 当前按同批构建和整体替换使用,不承诺不同版本 V1 artifact 混用。
  • 本次未修改公开 API,也未修改 build_fwk.sh 等公共构建脚本。
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 lfz2812 的贡献)
Llfz2812成员
11 天前 添加了label:enhancement
Llfz2812成员
11 天前 创建了 pull request,commit 7494a977
Llfz2812成员
11 天前 update merge request[project id: 8824148, iid: 4320, commit_id: 1c9e019d42f3d715dbef23f8727325a7b43b9605] virtual merging success
Llfz2812成员
11 天前 强制推送  22 个提交:7494a977-21 commits from branch develop813f5a04-feat: support Python custom op proto registration
Llfz2812成员
11 天前 update merge request[project id: 8824148, iid: 4320, commit_id: 817bdb1b5f71af3e4c3387a56970ed79a93ba075] virtual merging success
此处折叠了518条消息 查看更多
黄桂军
黄桂军成员
3 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
3 天前 添加了label:lgtm
张德鹏成员
2 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
2 天前 添加了label:approved
CANN-robotCANN-robot成员
2 天前 合入了pull request