已合并
更新自定义算子python callback生成的python代码的格式 #3554
Chang-an-HW创建于 6 天前
更新自定义算子python callback生成的python代码的格式 #3554
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Chang-an-HW 的贡献)6 天前 创建了 pull request,commit a35a182c
atomgit-bot
6 天前 评论:
6 天前 评论:
变更摘要
该 PR 更新了自定义算子 Python callback 生成代码的格式,将原先基于 EagerExecuteOp/EagerOpExecutionContext 的执行模型,改为基于 GE schema-bound 执行框架的格式:生成的类不再继承 EagerExecuteOp,execute 方法改为显式声明位置参数和 keyword-only 属性参数,并在函数体内通过 get_execute_ctx() 获取上下文。为保持 REG_OP 原型与 Python 执行签名一致,代码生成侧抽象出了统一的 RegOpProto/RegOpInput/RegOpAttr 描述结构,由 build_reg_op_proto 作为单一事实来源同时供 C++ REG_OP 文本和 Python execute 签名生成使用,并同步更新了依赖检测与相关单元测试。
主要改动
- 引入统一的 REG_OP 原型描述结构:在
custom_op_codegen_common.py中新增RegOpInput、RegOpAttr、RegOpProto三个 frozen dataclass 及build_reg_op_proto,将输入端口和属性信息从SchemaInfo统一推导出来,供 C++REG_OP生成与 Python execute 签名共同使用。 - 重构
generate_reg_op并新增 Triton 输入迭代器:generate_reg_op改为基于build_reg_op_proto生成.INPUT/.OPTIONAL_INPUT/.DYNAMIC_INPUT与.ATTR;同时新增_iter_triton_hop_reg_op_inputs,统一枚举 Triton HOP 的 tensor/scalar/TMA/grid 输入,避免 schema 与 Python 参数列表漂移。 - Python execute 改为 schema-bound 签名:在
custom_op_codegen_python.py中新增_safe_param_name、_execute_param_names和_generate_execute_signature,生成的类为普通类,execute签名形如def execute(self, 位置参数, *, 属性参数),并在函数内使用ctx = get_execute_ctx()获取执行上下文。 _generate_buildstack与 Triton execute 生成逻辑改用参数变量:原先通过ctx.get_input_tensor/get_optional_input_tensor/get_dynamic_input_tensor提取输入的逻辑,改为直接从 execute 参数读取并包装/解析;generate_triton_hop_execute也改为按ordered_inputs生成的参数处理 tensor、scalar、TMA 和 grid 输入,并移除return True。- 依赖检测与测试同步更新:
custom_op_pre_scan.py、相关 smoke/st 测试将ge.custom_op的导入从EagerExecuteOp, register_op_impl调整为get_execute_ctx, register_op_impl,并新增/修改用例以验证 schema-bound 签名、无return True、Triton HOP 执行参数绑定等行为。


atomgit-bot
6 天前 评论:
6 天前 评论:
6 天前 添加了label:smoke-pipeline-running
6 天前 添加了label:stat/needs-squash
此处折叠了85条消息 查看更多
ascend-robot
3 天前 评论:
3 天前 评论:
流水线 PR-pipeline_torchair#3731 [ commitID:018f6602 ] 已完成
>>>代码风格自动修复执行成功(无修复内容)
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_x86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ✅ | >>> |
| pre-commit | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 流水线 | PR-pipeline_torchair | ✅ | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


dingdairong
3 天前 评论:
3 天前 评论:
/lgtm


薛鹏
3 天前 评论:
3 天前 评论:
/approve


3 天前 添加了label:approvedlgtm
3 天前 合入了pull request
更新自定义算子python callback生成的python代码的格式