mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Update SkipLayerNorm fusion rules (#13350)
### Description <!-- Describe your changes. --> The subgraph below meet the SkipLayerNorm fusion pattern, but the fusion rules also required every input dimension has a certain value. So the subgraph below cannot fused to SkipLayerNorm. subgraph we want to fuse  fusion pattern 3 [Sub1] [Sub2] \ / \ / \ / Add1 | LayerNormalization This change allow inputs of FirstAdd operator has dimension which only has dim_param. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Co-authored-by: peixuanzuo <peixuanzuo@linmif39a000004.zvflicr54joexhdgnhvmxrxygg.phxx.internal.cloudapp.net>
This commit is contained in:
parent
ac48bdec89
commit
a0cc289be6
1 changed files with 7 additions and 2 deletions
|
|
@ -48,8 +48,13 @@ static bool CheckFirstAdd(Node& add, ProviderType providertype) {
|
|||
if (!utils::HasDimValue(add_input1_shape->dim(i)) ||
|
||||
!utils::HasDimValue(add_input2_shape->dim(i)) ||
|
||||
add_input1_shape->dim(i).dim_value() != add_input2_shape->dim(i).dim_value()) {
|
||||
is_valid_input = false;
|
||||
break;
|
||||
// Allow dimension only has dim_param.
|
||||
if (!utils::HasDimParam(add_input1_shape->dim(i)) ||
|
||||
!utils::HasDimParam(add_input2_shape->dim(i)) ||
|
||||
add_input1_shape->dim(i).dim_param() != add_input2_shape->dim(i).dim_param()) {
|
||||
is_valid_input = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_valid_input;
|
||||
|
|
|
|||
Loading…
Reference in a new issue