Skip to content

Commit

Permalink
Add parser support for SUM tflite operator
Browse files Browse the repository at this point in the history
  • Loading branch information
inadob committed Oct 22, 2019
1 parent 72dfa60 commit d4dd435
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(self, model, subgraph, exp_tab):
'REDUCE_MAX': self._convert_reduce_max,
'MEAN': self._convert_reduce_mean,
'REDUCE_PROD': self._convert_reduce_prod,
'SUM': self._convert_reduce_sum,
'FULLY_CONNECTED': self.convert_fully_connected,
'PAD': self.convert_pad,
'PACK': self.convert_pack,
Expand Down Expand Up @@ -672,6 +673,9 @@ def _convert_reduce_mean(self, op):
def _convert_reduce_prod(self, op):
return self._convert_reduce(_op.reduce.prod, op)

def _convert_reduce_sum(self, op):
return self._convert_reduce(_op.reduce.sum, op)

def convert_fully_connected(self, op):
"""Convert TFLite fully connected"""
try:
Expand Down
9 changes: 9 additions & 0 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,14 @@ def _test_reduce_prod(data, keep_dims=None):
""" One iteration of reduce_prod """
return _test_reduce(math_ops.reduce_prod, data, keep_dims)

#######################################################################
# Reduce_sum
# -----------

def _test_reduce_sum(data, keep_dims=None):
""" One iteration of reduce_prod """
return _test_reduce(math_ops.reduce_sum, data, keep_dims)


def _test_forward_reduce(testop):
""" Reduce """
Expand All @@ -732,6 +740,7 @@ def test_all_reduce():
_test_forward_reduce(_test_reduce_max)
_test_forward_reduce(_test_reduce_mean)
_test_forward_reduce(_test_reduce_prod)
_test_forward_reduce(_test_reduce_sum)


#######################################################################
Expand Down

0 comments on commit d4dd435

Please sign in to comment.