mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-27 20:02:15 +00:00
Not fuse SkipLayerNorm when add has initializer input (#5123)
This commit is contained in:
parent
cd56ab197c
commit
89509f256a
1 changed files with 11 additions and 0 deletions
|
|
@ -21,6 +21,17 @@ class FusionSkipLayerNormalization(Fusion):
|
|||
|
||||
def fuse(self, node, input_name_to_nodes, output_name_to_node):
|
||||
add = self.model.get_parent(node, 0, output_name_to_node)
|
||||
|
||||
# In some models there is input_ids->gather->add->LayerNorm and one of input of the
|
||||
# add node is initializer with fixed shape which should not be fused into SkipLayerNorm
|
||||
for add_input in add.input:
|
||||
if self.model.get_initializer(add_input) != None:
|
||||
return
|
||||
|
||||
# The number of input node of add should be 2
|
||||
if len(self.model.get_parents(add)) != 2:
|
||||
return
|
||||
|
||||
if add is not None and add.op_type == 'Add' and self.model.is_safe_to_fuse_nodes(
|
||||
[add, node], node.output, input_name_to_nodes, output_name_to_node):
|
||||
self.nodes_to_remove.extend([add, node])
|
||||
|
|
|
|||
Loading…
Reference in a new issue