Pull Request已成功合入, 合并人@CANN-robot
(感谢 fary86 的贡献)变更摘要
本 PR(feat: remove Om2Tensor)将 OM2 模型的对外加载/运行接口从旧的 Om2ModelCreate/Om2ModelLoad/Om2ModelRun/Om2ModelRunAsync/Om2ModelDestroy 一套分离式 API,重构为统一使用 Config/Output 结构体的 GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload 新接口,模型句柄类型 om2::Om2ModelHandle 相应更名为 GertModelHandle;codegen 代码生成、Om2ModelExecutor 执行器及对应单元/集成测试的 mock 接口均同步适配。
主要改动
- 接口重构为统一 Config/Output 结构体: 新增
GertModelLoadConfig、GertModelRunConfig、GertModelUnloadConfig与GertModelLoadOutput、GertModelRunOutput、GertModelUnloadOutput六个结构体,首字段均为struct_size版本号,将原Om2ModelCreate的众多分散参数合并到GertModelLoadConfig中;GertModelLoad将原 Create+Load 两步合并,GertModelUnload取代Om2ModelDestroy。 - 句柄类型重命名:
om2::Om2ModelHandle全局替换为GertModelHandle(仍为void *类型别名),同时移除interface_file_code_generator中的BuildOm2ModelHandleAlias、BuildOm2ProfInfosStruct等构造函数及program_generator.cc中对应生成逻辑。 Om2ProfInfos结构调整:model_dump_c_api.h中将version/count字段由uint32_t改为uint64_t struct_size/uint64_t count,并补充默认初始化值。Om2ModelExecutor适配新接口:runtime/om2/om2_model_executor.cc中ResolveSymbols改为按新符号名GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload解析,加载流程用GertModelLoadConfig组装参数并通过GertModelLoadOutput回传rt_model_handle,同步/异步运行改为传入 config/output 结构体,资源释放改用unload_func,并移除独立的LoadModel()方法。- codegen 生成内容与测试同步更新:
stable_part_provider.cc中新增生成GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload及上述结构体的代码(底层仍转发调用Om2ModelCreate等实现),多个 UT/ST 测试(如test_om2.cc、control_task_code_builder_unittest.cc、om2_model_executor_unittest.cc等)的 mock.so源码与断言均改为新接口。


代码审查
审查总结
发现统计
- P1:1 个
- P2:1 个
- P3:1 个
各变更文件审查结论
| 文件 | 结论 |
|---|---|
| base/common/om2/codegen/emitter/stable_parts/stable_part_provider.cc | P2 — 新公开 API 的 uint64_t 配置字段被静默窄化传入旧版 int/int32 型内部函数(GertModelRun 的 timeout、GertModelLoad 的 model_id/priority/bin_num 等) |
| base/common/om2/codegen/file_code_generator/interface_file_code_generator.cc | no issues(仅重构声明;已核对函数声明顺序、GertModelHandle typedef 置于 extern "C" 内、无遗留 Om2ModelHandle 引用) |
| base/common/om2/codegen/file_code_generator/interface_file_code_generator.h | no issues(仅删除两个方法声明,无遗留调用方) |
| base/common/om2/codegen/program_generator.cc | no issues(仅删除两处 push;接口头中 struct 定义先于函数声明,顺序正确) |
| inc/framework/runtime/dump/model_dump_c_api.h | P3 — Om2ProfInfos::count 改为 uint64_t 后,executor 日志 %u 格式不匹配(潜在 -Werror=format 编译风险) |
| runtime/om2/om2_model_executor.cc | P1 — 三处 C++20 designated initializer({.field = ...})被引入到 C++17 代码库,存在编译失败风险 |
| tests/ge/st/testcase/test_om2.cc | no issues(fake .so 与新契约一致) |
| tests/ge/st/testcase/test_om2_online.cc | no issues(fake .so 与新契约一致) |
| tests/ge/ut/ge/common/control_task_code_builder_unittest.cc | no issues(期望串与生成器输出一致) |
| tests/ge/ut/ge/common/program_generator_unittest.cc | no issues(期望串与生成器输出一致) |
| tests/ge/ut/ge/executor/om2_model_executor_unittest.cc | no issues(mock 与 trace 断言已同步更新) |
| tests/ge/ut/ge/executor/om2_model_manager_unittest.cc | no issues(fake .so 与新契约一致) |
| tests/ge/ut/ge/graph/execute/model_executor_unittest.cc | no issues(fake .so 与新契约一致) |
整体风险判断
本次变更把 OM2 的 create/load/run/destroy 四接口合并为 struct 化的 GertModel* 接口,运行时 executor、codegen 生成代码与各测试 mock 三侧的结构体布局保持一致,跨文件契约(GertModelLoadConfig/GertModelRunConfig/GertModelLoadOutput 等)核对无错位,主流程 create+load 合并与 unload 流程重构在逻辑上是自洽的。主要风险集中在两点:(1) runtime 源码引入 C++20 designated initializer,与仓库统一的 C++17 + -Wall -Werror 构建约定冲突,存在编译失败风险(P1);(2) 新 API 的 u64 参数与内部 int 型实现之间的静默窄化(P2)。两处都不影响当前 executor 内部调用路径的正确性,但属于可复现的边界/构建风险,建议在合入前修复。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


/lgtm


/approve


Pull Request
描述
本 PR(
feat: remove Om2Tensor)将 OM2 模型的对外加载/运行接口从旧的Om2ModelCreate/Om2ModelLoad/Om2ModelRun/Om2ModelRunAsync/Om2ModelDestroy一套分离式 API,重构为统一使用 Config/Output 结构体的GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload新接口,模型句柄类型om2::Om2ModelHandle相应更名为GertModelHandle;codegen 代码生成、Om2ModelExecutor执行器及对应单元/集成测试的 mock 接口均同步适配。主要改动
GertModelLoadConfig、GertModelRunConfig、GertModelUnloadConfig与GertModelLoadOutput、GertModelRunOutput、GertModelUnloadOutput六个结构体,首字段均为struct_size版本号,将原Om2ModelCreate的众多分散参数合并到GertModelLoadConfig中;GertModelLoad将原 Create+Load 两步合并,GertModelUnload取代Om2ModelDestroy。om2::Om2ModelHandle全局替换为GertModelHandle(仍为void *类型别名),同时移除interface_file_code_generator中的BuildOm2ModelHandleAlias、BuildOm2ProfInfosStruct等构造函数及program_generator.cc中对应生成逻辑。Om2ProfInfos结构调整:model_dump_c_api.h中将version/count字段由uint32_t改为uint64_t struct_size/uint64_t count,并补充默认初始化值。Om2ModelExecutor适配新接口:runtime/om2/om2_model_executor.cc中ResolveSymbols改为按新符号名GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload解析,加载流程用GertModelLoadConfig组装参数并通过GertModelLoadOutput回传rt_model_handle,同步/异步运行改为传入 config/output 结构体,资源释放改用unload_func,并移除独立的LoadModel()方法。stable_part_provider.cc中新增生成GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload及上述结构体的代码(底层仍转发调用Om2ModelCreate等实现),多个 UT/ST 测试(如test_om2.cc、control_task_code_builder_unittest.cc、om2_model_executor_unittest.cc等)的 mock.so源码与断言均改为新接口。变更类型
请选择本次引入的变更类型:
关联的Issue
如何测试
描述测试此变更的步骤和前提条件:
1.
2.
核对清单
其他信息
在此添加任何其他关于本次 PR 的说明。