Merged
feat: 支持 DT_HIFLOAT4_SCALE 数据类型 #4737
feat: 支持 DT_HIFLOAT4_SCALE 数据类型 #4737
Merged
shangdfAdd on Sep 4
shangdfCollaborators
Sep 4

Pull Request

描述

新增 DT_HIFLOAT4_SCALE(hifloat4 带缩放因子的 4bit 浮点)数据类型支持,与 metadef 仓 C_DT_HIFLOAT4_SCALE = 43 配套。GE 侧登记内容包括:

  • proto 定义:ge_ir.proto、dump_task.proto 的 DataType 枚举新增 DT_HIFLOAT4_SCALE = 42
  • atc/模型转换:atc --output_type 与 netoutput 的输出类型映射新增 HIF4SCALE,option_utils 校验提示文案同步
  • 单算子解析:single_op_parser 的 kDataTypeDict 新增 hifloat4_scale 字符串映射
  • 编译 pass:cond_remove_pass、switch_dead_branch_elimination 的 1 字节判值分支、IsFloatType(atomic_memory_assigner.h)登记新类型
  • Host CPU 引擎:PrepareOutputs 支持的数据类型集合登记
  • dump/序列化:datatype_util dump 数据类型映射、ge_tensor/serialization_util 序列化双向映射、type_utils_inner 字符串映射补充
  • Python API:pyge DataType 枚举新增 DT_HIFLOAT4_SCALE = 43,DT_MAX 适配为 44,中英文 API 文档与 UT 断言同步
  • 说明:constant_clip_pass 的 clip 上下限尚未适配 hif4_scale,与原方案一致保持现状并在函数处注释标记

变更类型

关联的Issue

无

如何测试

  1. 运行 pyge UT:tests/ge/ut/ge/graph/pyge_tests/types_test.py(含 DT_HIFLOAT4_SCALE=43、DT_MAX=44 断言)
  2. atc 转换时指定 --output_type=HIF4SCALE 验证输出类型映射
  3. 单算子 IR 传入 hifloat4_scale 数据类型字符串验证解析

核对清单

其他信息

依赖 metadef 仓头文件新增 C_DT_HIFLOAT4_SCALE = 43(metadef develop 已包含),GE 构建使用该发布包头文件,本仓不重复定义 C++ 枚举。原 diff 中 IsFloatType 位于 graph_mem_assigner.h,当前 develop 上该函数已迁移至 atomic_memory_assigner.h,本次修改跟随函数落位。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for shangdf's contribution.)
SshangdfCollaborators
Sep 4 Created pull request, commit 0a9a7881
atomgit-bot
atomgit-bot
Sep 4 Comments:

变更摘要

本 PR 为 GE 侧新增 DT_HIFLOAT4_SCALE(hifloat4 带缩放因子的 4bit 浮点)数据类型支持,与 metadef 仓 C_DT_HIFLOAT4_SCALE = 43 配套,覆盖 proto 枚举、atc 输出类型映射、单算子解析、编译 pass、Host CPU 引擎、dump/序列化映射以及 pyge Python API 等全链路登记。其中 constant_clip_pass 的 clip 上下限按原方案暂不适配 hif4_scale,仅在函数处注释标记。

主要改动

  • proto 枚举定义:ge_ir.proto 与 dump_task.proto 的 DataType/OutputDataType 枚举新增 DT_HIFLOAT4_SCALE = 42,为序列化与 dump 提供协议层支持。
  • atc 输出类型映射:omg.cc、option_utils.cc、net_output_pass.cc 的字符串到 ge::DataType 映射表新增 HIF4SCALE -> ge::DT_HIFLOAT4_SCALE,option_utils.cc 中 kOutputTypeSupport 校验提示文案同步补充 HIF4SCALE。
  • 单算子解析与编译 pass:single_op_parser.cc 的 kDataTypeDict 新增 hifloat4_scale 字符串映射;cond_remove_pass.cc 与 switch_dead_branch_elimination.cc 的 1 字节判值分支、atomic_memory_assigner.h 的 IsFloatType 均登记新类型。
  • dump/序列化与大小映射:datatype_util.cc、ge_tensor.cc、serialization_util.cc、type_utils_inner.cc 新增双向映射;ge_api.cc/ge_api_v2.cc 的 CONST_OPDATA_TYPE_SIZE_MAP 按 kGesizefloat 登记其大小,PrintOutputResult 增加按 float 打印输出的分支。
  • Host CPU 引擎与 Python API:host_cpu_engine.cc 的 PrepareOutputs 支持类型集合加入 DT_HIFLOAT4_SCALE;pyge types.py 的 DataType 新增 DT_HIFLOAT4_SCALE = 43 并将 DT_MAX 调整为 44,types_test.py 断言同步更新。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 4 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 4 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 4 Comments:

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, Mexyy, zhanj (3/2) ✅ yangyongqiang0606 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

shangdf, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
126 messages are collapsed here。 See more
wangyuchen
wangyuchenCollaborators
Sep 11 Comments:

/check-pr

likedislike
CANN-robot
CANN-robotCollaborators
Sep 11 Comments:

The following label is not ready.

approved: Please wait for committers to review the code.

likedislike
yangyongqiang
yangyongqiangCollaborators
Sep 11 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 11 Added label: approved
CANN-robotCANN-robotCollaborators
Sep 11 Merged pull request