Skip to content

Commit ef5df7a

Browse files
committed
Merge branch 'feature/absorb-bias-into-multithreshold' into dev
2 parents a5d32f2 + ee2d227 commit ef5df7a

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

src/finn/transformation/streamline/absorb.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@
2929
import numpy as np
3030
import qonnx.core.data_layout as DataLayout
3131
import warnings
32-
33-
# Protobuf onnx graph node type
34-
from onnx import NodeProto # noqa
3532
from onnx import helper as oh
36-
# Protobuf onnx graph node type
37-
from onnx import NodeProto # noqa
38-
# QONNX wrapper of ONNX model graphs
39-
from qonnx.core.modelwrapper import ModelWrapper
4033
from qonnx.core.datatype import DataType
34+
35+
# QONNX wrapper of ONNX model graphs
4136
from qonnx.core.modelwrapper import ModelWrapper
4237
from qonnx.custom_op.registry import getCustomOp
4338
from qonnx.transformation.base import Transformation
@@ -47,6 +42,9 @@
4742

4843
from finn.transformation.util import group_inputs_by_category
4944

45+
# Protobuf onnx graph node type
46+
from onnx import NodeProto # noqa
47+
5048

5149
# Note: Old name kept for compatibility reasons but actually allows to absorb
5250
# any bias irrespective of signedness which might result in changed signedness
@@ -186,19 +184,6 @@ def apply(self, model: ModelWrapper):
186184
return model, graph_modified
187185

188186

189-
# Groups inputs by categories, i.e., groups dynamic inputs first, followed by
190-
# initializers. Keeps order of inputs in each category.
191-
def group_inputs_by_category(node: NodeProto, model: ModelWrapper): # noqa
192-
# First select all dynamic inputs, which are those without initializer
193-
# tensor
194-
dynamics = [i for i in node.input if model.get_initializer(i) is None]
195-
# Select all input which are initializers, which, by exclusion, are all
196-
# those not among the dynamic inputs
197-
initializers = [i for i in node.input if i not in dynamics]
198-
# Return lists of dynamic anc initializer inputs
199-
return dynamics, initializers
200-
201-
202187
class AbsorbAddIntoMultiThreshold(Transformation):
203188
"""Absorb preceding Add ops into MultiThreshold by updating the threshold
204189
values. Only scalar/1D add vectors can be absorbed."""

0 commit comments

Comments
 (0)