Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Support infer_datatype for flatten layer (#30)
Browse files Browse the repository at this point in the history
* Support infer_datatype for flatten layer

* [InferDT] add more identity op types for datatype inference

* [Lint] fix linting issues

Co-authored-by: Yaman Umuroglu <[email protected]>
  • Loading branch information
fpjentzsch and maltanar authored May 17, 2021
1 parent 2c08044 commit ac0b86a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/finn/transformation/infer_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
def _infer_node_datatype(model, node):
"""Infer output datatype(s) for a particular node. Returns True if any
changes were made."""
dt_identity_optypes = ["Reshape", "Transpose"]
dt_identity_optypes = [
"Reshape",
"Transpose",
"Flatten",
"Slice",
"Gather",
"Identity",
]
idtypes = list(map(lambda x: model.get_tensor_datatype(x), node.input))
odtypes = list(map(lambda x: model.get_tensor_datatype(x), node.output))
op_type = node.op_type
Expand Down
2 changes: 1 addition & 1 deletion tests/transformation/test_4d_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate_random_input(model):


def set_all_initializers(model):
""" Sets all initializers of the graph to a random value. """
"""Sets all initializers of the graph to a random value."""
for n in model.graph.node:
if len(n.input) > 1:
init_name = n.input[1]
Expand Down
2 changes: 1 addition & 1 deletion tests/transformation/test_batchnorm_to_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_batchnorm_to_affine_shufflenet():

@pytest.mark.parametrize("epsilon", [0.0, 0.00001, 0.001])
def test_batchnorm_to_affine_epsilon(epsilon):
""" Dummy batchnorm node to test out the epsilon attribute. """
"""Dummy batchnorm node to test out the epsilon attribute."""

batchnorm_node = onnx.helper.make_node(
"BatchNormalization",
Expand Down

0 comments on commit ac0b86a

Please sign in to comment.