Skip to content

Commit

Permalink
better handle cases when there is no previous node
Browse files Browse the repository at this point in the history
  • Loading branch information
jmitrevs committed Dec 4, 2024
1 parent 76d06e7 commit 915d2e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hls4ml/model/optimizer/passes/batchnorm_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class FuseConsecutiveBatchNormalization(OptimizerPass):
"""

def match(self, node):
prev_node = node.get_input_node(node.inputs[0])
prev_node = node.get_input_node()
basic_match = (
isinstance(node, BatchNormalization)
and isinstance(prev_node, BatchNormalization)
Expand Down Expand Up @@ -194,7 +194,7 @@ def match(self, node):
return False

def transform(self, model, node):
prev_node = node.get_input_node(node.inputs[0])
prev_node = node.get_input_node()

prev_map = prev_node.get_output_use_map()
if len(prev_map[prev_node.outputs[0]]) > 1:
Expand Down
2 changes: 1 addition & 1 deletion hls4ml/model/optimizer/passes/bn_fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FuseBatchNormalization(OptimizerPass):
"""

def match(self, node):
prev_node = node.get_input_node(node.inputs[0])
prev_node = node.get_input_node()
basic_match = (
isinstance(node, BatchNormalization)
and isinstance(prev_node, (Dense, Conv1D, Conv2D))
Expand Down

0 comments on commit 915d2e1

Please sign in to comment.