LayerNormFusionPass / LayerNormInferenceFusionPass / LayerNormONNXFusionPass / LayerNormONNXMULFusionPass / LayerNormRemoveBroadcastFusionPass 五条融合规则的平台校验位于 MeetRequirements()(匹配结果过滤阶段)。不支持的平台下仍会完整构造 pattern(分别为 32、64、96、40、1 个,合计 233 个)并参与结构匹配;且 MeetRequirements() 在每次匹配回调中重复查询平台信息。
LayerNormFusionPass
LayerNormInferenceFusionPass
LayerNormONNXFusionPass
LayerNormONNXMULFusionPass
LayerNormRemoveBroadcastFusionPass
MeetRequirements()
将 IsSupportedPlatform() 校验前移到 Patterns() 开头:不支持的平台或平台信息获取失败时返回空 pattern 列表(框架对空 pattern 返回 GRAPH_NOT_CHANGED,行为安全);移除 MeetRequirements() 中的重复校验。
IsSupportedPlatform()
Patterns()
GRAPH_NOT_CHANGED
关联 PR:https://gitcode.com/cann/ops-nn/pull/11299
一、背景信息
LayerNormFusionPass/LayerNormInferenceFusionPass/LayerNormONNXFusionPass/LayerNormONNXMULFusionPass/LayerNormRemoveBroadcastFusionPass五条融合规则的平台校验位于MeetRequirements()(匹配结果过滤阶段)。不支持的平台下仍会完整构造 pattern(分别为 32、64、96、40、1 个,合计 233 个)并参与结构匹配;且MeetRequirements()在每次匹配回调中重复查询平台信息。二、价值/作用
三、设计方案
将
IsSupportedPlatform()校验前移到Patterns()开头:不支持的平台或平台信息获取失败时返回空 pattern 列表(框架对空 pattern 返回GRAPH_NOT_CHANGED,行为安全);移除MeetRequirements()中的重复校验。关联 PR:https://gitcode.com/cann/ops-nn/pull/11299