已合并
补充tla.mmad中hf32模式支持 #1104
init__zhb__创建于 25 天前
补充tla.mmad中hf32模式支持 #1104
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 init__zhb__ 的贡献)25 天前 创建了 pull request,commit 6e3e414c
atomgit-bot
25 天前 评论:
25 天前 评论:
变更摘要
该 PR 为 tla.mmad 补充了 use_hf32 参数,用于控制 FP32 操作数在 L0A/L0B 上进行 HF32 舍入(等价于 AscendC::SetHF32Mode)。改动贯穿前端 DSL API、MLIR 算子定义与 Python 绑定、以及底层 lowering 流程:新增 BoolAttr 属性并通过 hivm::SetCtrlOp 操作 CTRL[46] 控制位,同时补充了函数级统一设置与逐 mmad 设置的回退策略、函数退出时的默认值恢复逻辑,以及相应的测试用例。
主要改动
Tla_MmadOp算子定义扩展: 在Tla.td中为tla.mmad新增必选属性BoolAttr:$use_hf32,并补充了该属性对应CTRL[46]控制位的语义说明。- 前端 DSL API 扩展: 在
core_api.py的mmad()中新增use_hf32: bool = False参数,校验其必须为bool,并生成mlir_ir.BoolAttr传递给底层算子;同时更新了生成的tla_ops_gen.py绑定以接收并设置use_hf32。 - Lowering 新增 HF32 控制位逻辑: 在
TlaCubeRegionPass.cpp中新增Hf32ModeBit = 46,通过hivm::SetCtrlOp设置CTRL[46];当函数内所有mmad的use_hf32一致时在函数入口统一设置一次,混用 true/false 时改为在每个mmad前逐条设置。 - 函数退出时恢复默认值: 在
TlaPrologueEpiloguePass.cpp中新增对CTRL[46]的复位逻辑,在函数末尾的PIPE_ALLbarrier 前或函数结束处写入hivm::SetCtrlOp将 HF32 模式恢复为false。 - 测试补充与更新: 新增
mmad-hf32.mlir覆盖 true、默认 false、双 true 与混合场景的 lowering 行为;更新现有tla.mmad相关 lit 测试以携带use_hf32,并在test_frontend_lowering.py中新增参数发射与非法参数校验测试。


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


此处折叠了187条消息 查看更多
20 天前 添加了label:lgtmapproved
20 天前 合入了pull request
CANN-robot
20 天前 评论:
20 天前 评论:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
# 注意hf32模式需在A, B均为f32时启用 # 可支持的 hf32 模式: # ``tla.params.Hf32Mode.HF32_NEAREST_ZERO`` # ``tla.params.Hf32Mode.HF32_NEAREST_EVEN`` if tla.const_expr(hf32_mode != tla.params.Hf32Mode.HF32_DISABLE and dtype_a == tla.Float32 and dtype_b == tla.Float32): tla.mmad(l0_c, l0_a, l0_b, init_c=init_c, unit_flag=unit_flag, hf32_mode=hf32_mode) else: tla.mmad(l0_c, l0_a, l0_b, init_c=init_c, unit_flag=unit_flag)to_hf32模拟尾数截断;关联的Issue
原因
测试
文档更新
类型标签