已合并
feat(jit): support pointer and struct tiling constants #5719
XuebinYang创建于 2 天前
feat(jit): support pointer and struct tiling constants #5719
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 XuebinYang 的贡献)2 天前 创建了 pull request,commit 6d68a9f4
atomgit-bot
2 天前 评论:
2 天前 评论:
变更摘要
本 PR 为 JIT 常量化编译引入按值传递的结构体 tiling 支持:此前所有 constant_infos 项都必须提供 byte_size 并与 argsBytes 严格相等,无法表达按值传递的结构体。改动为 constant_infos[] 新增 arg_type 字段(支持 pointer 与 struct,缺省为 struct),并同步更新了 manifest 校验器、ACLRTC 运行时构建逻辑及两个 Python manifest 生成器,同时要求旧的 pointer manifest 补充 arg_type: pointer 或重新生成。
主要改动
- 新增
arg_type字段并定义缺省值:kernel_compilation_plan_builder.cpp中BuildConstantSourcePatches通过constantInfo.value("arg_type", STRUCT_ARGUMENT_TYPE)读取类型,支持pointer/struct两种取值并拒绝其他值;resource_manifest_validator.cpp的ValidateConstant同样以struct作为缺省类型进行校验。 - 按类型分支确定大小来源:
pointer常量使用 manifest 中的byte_size(必填且非零);struct常量改用argsBytes[parameter_index]提供的字节数,并禁止在 manifest 中携带byte_size,同时运行时校验struct的argsBytes必须非零、argsAddr必须提供。 - validator 校验逻辑重构:
resource_manifest_validator.cpp移除了原先无条件要求的byte_size必填及"恰好五个字段"的检查,改为保留逐字段必填与类型检查、按pointer/struct分支校验大小字段,并依据允许的字段数量(4 + 是否含arg_type+ 是否含byte_size)拒绝额外字段。 - Python manifest 生成器同步输出
pointer:tools/build/asc_op_compile_base/adapter/static_compile_resource_generator.py与tools/build/asc_op_compile_base/asc_op_compiler/static_compile_resource_generator.py中的ManifestPackageWriter均在写出constant_infos项时固定补充"arg_type": "pointer"。 - 测试覆盖与既有用例迁移: 更新
test_static_compile_resource_generator.py、test_kernel_compilation_plan_builder.cpp、test_kernel_specialization_session.cpp、test_resource_manifest_validator.cpp,新增对显式/缺省struct、禁止struct携带byte_size、pointer必填byte_size、两种大小来源及零长度非法参数的覆盖。


不准确?
atomgit-bot
2 天前 评论:
2 天前 评论:
2 天前 添加了label:cann-cla/yes
CANN-robot
2 天前 评论:
2 天前 评论:
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/asc-devkit | ✅ sjtulxh, YANXI_ZHAO (2/2) | ✅ sjtulxh, YANXI_ZHAO (2/1) |
| tools/aclrtc | ✅ YANXI_ZHAO, sjtulxh (2/2) | ✅ YANXI_ZHAO (1/1) |
| tools/build | ✅ sjtulxh, YANXI_ZHAO (2/2) | ✅ sjtulxh (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
XuebinYang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了97条消息 查看更多
YANXI_ZHAO
1 天前 评论:
1 天前 评论:
/lgtm
/approve


1 天前 添加了label:lgtm
1 天前 添加了label:approved
1 天前 合入了pull request
描述
JIT 常量化编译此前要求所有 constant_infos 项提供 byte_size,并与 argsBytes 严格相等,无法表达按值传递的结构体 tiling。
新增 constant_infos[].arg_type,支持 pointer 和 struct,缺省为 struct。ACLNN manifest 生成器固定输出 arg_type: pointer 和按 kernel 确定的 byte_size,不提供类型配置。pointer 常量使用 manifest 的 byte_size;struct 常量只使用 argsBytes[parameter_index],禁止在 manifest 中提供 byte_size。pack validator 和运行时均拒绝 struct 携带 byte_size。
公用 ManifestConstant 类统一 exporter 与 runtime 的 constant 字段契约。ParseDefinition 解析并校验定义,BindArgument 绑定参数地址与大小,屏蔽 pointer/struct 差异;私有成员维护解析及绑定状态,失败保留原状态,重新解析成功后清除旧绑定。错误直接记录 plog。删除 ConstantSizeRule 和自由解析入口,模块兼容 C++11,不依赖 ACLRTC。
ACLRTC 计划构建按解析和绑定两个职责封装。CompilationManifestParser 选择本次 kernel 的 basic/SK 配置,复用公用常量解析,输出持有数据的 CompilationManifest;只保留 CompilationManifest、ManifestCommand 两个解析层接口结构体。KernelCompilationPlanBuilder 直接接收解析结果,绑定常量、路径、环境和命令选项,在全部检查成功后才读取常量字节,失败不修改调用者输出。删除旧 kernel_manifest_parser、ManifestText、重复的绑定中间结构和独立组装步骤,Builder 不再接触 JSON 或判断 pointer/struct。
能力不区分 ACLNN 或尖括号来源,不添加 ACLNN 标记;两种入口均可按参数语义使用 pointer/struct。
删除未产生行为差异的 Parsed/Bound 状态,仅保留 definitionParsed_。路径与环境展开明确命名为 ExpandPathAndEnvironmentReferences,有上限的整数读取命名为 ReadBoundedNonnegativeInteger,解析和执行命令的参数字段统一为 arguments。
Builder 先绑定编译和链接命令,最后由 BuildConstantSourcePatches 完成全部常量绑定、目标展开和 patch 生成,任一步校验失败都不读取常量内存。请求侧删除 KernelCompilationVariant,使用 enableSuperKernel 表达 SK 开关;ManifestObjectKind 仅描述单个 basic/sk 对象。调整现有保护内存 UT,使其覆盖绑定阶段的命令与链接失败。
命令先按顺序展开全部 options 引用,再将首项作为 executable,其余作为 arguments。支持首项引用同时包含可执行文件及多个选项,拒绝展开后的空命令;不递归展开 options 引用。
ParseSelectedObjects 按请求选择编译对象。启用 SK 但所选 kernel 只有 basic 时记录 INFO 日志并回退普通编译,不加入 SK 专用选项;basic 缺失或已存在的 sk 配置错误仍返回失败。复用现有 UT 比较回退与 basic 模式的编译、链接命令,不增加用例数量。
保留受保护内存、非零参数索引的 pointer/struct 混合用例及解析数据所有权检查。UT 按职责收敛:字段与参数绑定校验集中在 ManifestConstant,删除 Parser/Builder/exporter 的重复校验矩阵,公共测试仅在 exporter 目标运行一次。补充状态重置、失败保留原状态和重复解析/构建的必要回归。
两个 Python producer 镜像同步修改。旧 pointer manifest 必须补充 arg_type: pointer 或重新生成。
关联的Issue
暂无关联 Issue。
测试
文档更新
本 PR 不提交文档文件。
类型标签