| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
perf(tanh): 移除 arch35 DAG 层冗余 Cast 节点,类型转换改由 TanhCustom内cast逻辑完成 Co-authored-by: ywx1080114<yuanbin22@huawei.com> !5250 merge perf/tanh-remove-redundant-cast into master perf(tanh): 移除 arch35 DAG 层冗余 Cast 节点,类型转换改由 TanhCustom内cast逻辑完成 Created-by: yuanbin_22 Commit-by: ywx1080114 Merged-by: cann-robot Description: ## 描述 本 PR 优化 tanh 算子在 arch35 平台上的执行性能,通过移除 DAG 层的冗余 Cast 节点,将 FP16/BF16 与 FP32 之间的类型转换从软件 Cast 节点改为由 类型转换改由 TanhCustom内cast逻辑完成,减少不必要的寄存器搬运和转换开销。 | 文件 | 变更类型 | +行 | -行 | |------|----------|-----|-----| | math/tanh/op_kernel/arch35/tanh_dag.h | 内核优化 | +3 | -7 | 原 TanhDAG 结构为: CopyIn<U> → Cast<float, U> → TanhCustom<float> → Cast<U, float> → CopyOut<U> 其中 OpCopyIn0Cast(FP16/BF16→FP32)和 OpResultCast(FP32→FP16/BF16)是两个额外的软件 Cast 节点,带来冗余的寄存器搬运开销。 优化后 TanhDAG 结构为: CopyIn<U> → TanhCustom<U> → CopyOut<U> Cast 操作被移除,类型转换由 类型转换改由 TanhCustom内cast逻辑完成,无需额外的软件 Cast 节点。 具体修改: - 移除 OpCopyIn0Cast(Cast<T, U, CAST_MODE_NONE>)节点 - 移除 OpResultCast(Cast<U, T, CAST_MODE_RINT>)节点 - TanhCustom 模板参数从 <T>(float)改为 <U>(实际 dtype),内部通过 TanhCustom内cast的逻辑完成 类型转换 - TanhDAG 模板参数从 <typename U, typename T = float> 简化为 <typename U>,移除默认 float 类型参数 关联Issue #2993 - tanh 算子 arch35 平台 FP16/BF16/FP32 各 dtype 功能验证通过,精度与优化前一致 - 性能对比:FP16/BF16 路径吞吐提升(消除冗余 Cast 开销) - CI 流水线通过(ci-pipeline-passed) 不涉及 - [ ] Bug修复 - [ ] 新特性 - [x] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-math!5250 | 1 个月前 |