Closed
[Requirement|需求建议]: 新增SetSaturationFlag/GetSaturationFlag饱和模式语义接口 #716
ApeiriaNode_BookerAdd on May 21Closed at May 21
May 21 Added label: requirement
May 21 Associated milestone: Ascend C Release Plan 2026Q2
May 21 Remove milestone
May 21 Associated milestone: Ascend C Release Plan 2026Q2
May 21 Assign ApeiriaNode_Booker as responsible person
May 21 Assign chentianyu19 as responsible person
ApeiriaNode_Booker
May 21 Comments:
May 21 Comments:
代码已合入,关闭issue


May 21 changed custom state from 待办的 to 已完成
May 21 Close issue
May 21 Added label: Accepted
May 21 Added label: resolved
Backgroud(背景信息)
浮点数计算中涉及 INF / NAN 等特殊值处理。客户现场 INF / NAN 问题触发后,Ascend910B / Ascend910C 需要支持饱和模式配置能力。
已有
SetCtrlSpr/GetCtrlSpr属于底层 SPR 寄存器访问接口,直接面向寄存器 bit 位;而本需求是基于 SPR 能力再封装一层面向用户语义的饱和模式开关接口,即SetSaturationFlag/GetSaturationFlag。二者诉求不同,应作为独立需求跟踪。Origin(信息来源)
Benefit / Necessity(价值/作用)
SetCtrlSpr/GetCtrlSpr的风险,提高接口可读性和可维护性。Design(设计方案)
enum class SaturationMode { FLOAT, INT, CAST }template <SaturationMode mode> __aicore__ inline void SetSaturationFlag(bool enableSat)template <SaturationMode mode> __aicore__ inline bool GetSaturationFlag()SetSaturationFlag(true)表示开启饱和模式,等效于将对应 CTRL SPR bit 置为 0。SetSaturationFlag(false)表示关闭饱和模式,等效于将对应 CTRL SPR bit 置为 1。GetSaturationFlag()在对应 bit 为 0 时返回true,在对应 bit 为 1 时返回false。SaturationMode::FLOAT和SaturationMode::CAST。SaturationMode::INT,通过编译期报错提前拦截并给出明确提示。SetCtrlSpr/GetCtrlSpr能力实现,但不等同于 SPR 接口需求,应独立跟踪。Acceptance Criteria(验收标准)
SetSaturationFlag(true)能正确开启饱和模式,INF 饱和为 ±MAX,NAN 饱和为 0。SetSaturationFlag(false)能正确关闭饱和模式,INF / NAN 保持原输出。GetSaturationFlag()能正确查询当前饱和模式开关状态:对应 bit 为 0 时返回true,为 1 时返回false。SaturationMode::FLOAT、SaturationMode::CAST可正常编译并生效。SaturationMode::INT时编译期报错,提示该芯片版本仅支持FLOAT/CAST。SetCtrlSpr/GetCtrlSpr接口行为,不影响非目标芯片兼容性。