Pull Request已成功合入, 合并人@CANN-robot
(感谢 lidaoming1 的贡献)变更摘要
本 PR 为 OM2 executor 增加「资源申请」能力:模型加载时允许由外部传入 rt_model、stream、event、label、notify 等资源(通过新增的 GertModelExternalResources 结构体与 GertModelLoadConfig 扩展字段下发),并将工作内存的分配从 executor 侧下沉到 codegen 生成的 pbody 中(支持 reuse_zero_copy 零拷贝复用);同时将 dump/profiling 相关的公共数据结构由 Om2Task* 全面更名为 GertModel*(如 GertModelTaskDesc、GertModelArgKind),并新增一组资源查询 API(GertModelGetStreamNum 等)。此外还修复了 C++ 发射器对 switch/case 语句体的缩进处理。
主要改动
- 外部资源注入支持: 在
GertModelLoadConfig中新增external_rt_model、external_streams、external_events、external_labels、external_notifies及各自数量字段,Om2Model::InitResources签名扩展为接收reuse_zero_copy与const GertModelExternalResources &;codegen 的BuildInitStreamResources/BuildInitNotifyResources/BuildInitEventResources/BuildInitLabelResources在外部资源数量非 0 时改用外部资源(并校验数量一致),ReleaseResources通过新增的is_external_rt_model_、is_external_streams_、is_external_notifies_、is_external_events_、is_external_labels_标志跳过对外部资源的销毁,避免重复释放。 - 工作内存分配下沉至 codegen: 移除 executor 侧的
PrepareWorkPtr,GertModelLoadConfig.work_ptr直接透传(可为空);codegen 在InitResources中新增kModelWorkSize/kModelZeroCopySize常量,按reuse_zero_copy计算required_work_size,在work_ptr为空时自行调用AclrtMallocHelper分配,并用owns_total_dev_mem_记录归属以便在ReleaseResources中释放;om2_codegen_model_builder.cc读取ATTR_MODEL_ZERO_COPY_MEMORY_SIZE到RuntimeResourceSemantic.zero_copy_size,并校验其不超过total_mem_size。 - 公共结构体更名与接口收敛:
Om2TaskInfo→GertModelTaskDesc、Om2TaskIoEntry→GertModelTaskIoEntry、Om2L0TaskRawInfo→GertModelTaskRawInfo、Om2L0ArgSlotInfo→GertModelArgSlotInfo、Om2L0ArgKind→GertModelArgKind(改为uint64_t枚举并新增GERT_MODEL_ARG_INVALID_KIND),GertModelCallbacks→GertModelLoadCallbacks,字段l0_exception_dump_info→task_raw_info;同时移除接口头中的弱符号ReportDfxTaskPreprocess/ReportDfxTaskPostprocess声明及 codegen 侧的ReportOm2TaskPreprocess/ReportLaunchedOm2Task辅助函数,GertModelLoad/GertModelRun/GertModelRunAsync/GertModelUnload返回类型统一由int改为int32_t。 - 新增资源查询 API: 在
LoadAndRunFileCodeGenerator中新增BuildQueryResourceApis,以extern "C"导出GertModelGetStreamNum、GertModelGetStreamDesc、GertModelGetEventNum、GertModelGetEventDesc、GertModelGetLabelNum、GertModelGetNotifyNum、GertModelGetNotifyDesc,按 codegen 模型运行时语义返回各资源数量与 flag 描述;AclrtMalloc辅助函数由 load/run 文件生成器移至InterfaceFileCodeGenerator并改为inline。 - C++ 发射器 switch/case 缩进修复:
cpp_emitter.cc的Emit(BlockStmt)增加in_case_body状态,对CaseStmt所在的语句块按 case 层级增减缩进,保证switch(含嵌套switch)生成代码的缩进正确。


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 |
|---|---|---|
| repo-cann/ge | ✅ yangyongqiang0606, ClarkXie (2/2) | ✅ yangyongqiang0606 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lidaoming1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


compile


compile


/lgtm


/lgtm


/approve


Pull Request
描述
feat: OM2兼容性修改struct重命名和类型调整
feat: OM2 的pbody 内部申请workspace内存
feat: OM2 支持外部查询资源配置及申请
变更类型
请选择本次引入的变更类型:
关联的Issue
如何测试
描述测试此变更的步骤和前提条件:
1.
2.
核对清单
其他信息
在此添加任何其他关于本次 PR 的说明。