Skip to content

Commit

Permalink
[TFLITE]Round op parsing support added (#5022)
Browse files Browse the repository at this point in the history
  • Loading branch information
siju-samuel authored Mar 12, 2020
1 parent 95e7e34 commit 5e7fbae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/tvm/relay/frontend/tflite.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def __init__(self, model, subgraph, exp_tab):
'RESHAPE': self.convert_reshape,
'RESIZE_BILINEAR': self.convert_resize_bilinear,
'RESIZE_NEAREST_NEIGHBOR': self.convert_resize_nearest_neighbor,
'ROUND': self.convert_round,
'RSQRT': self.convert_rsqrt,
'SIN': self.convert_sin,
'SLICE': self.convert_slice,
Expand Down Expand Up @@ -676,6 +677,13 @@ def convert_floor(self, op):
'TFlite quantized FLOOR operator is not supported yet.')
return self._convert_unary_elemwise(_op.floor, op)

def convert_round(self, op):
"""Convert TFLite ROUND"""
if self.is_quantized(op):
raise tvm.error.OpNotImplemented(
'TFlite quantized ROUND operator is not supported yet.')
return self._convert_unary_elemwise(_op.round, op)

def convert_exp(self, op):
"""Convert TFLite EXP"""
if self.is_quantized(op):
Expand Down
10 changes: 10 additions & 0 deletions tests/python/frontend/tflite/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,15 @@ def _test_ceil(data):
def _test_floor(data):
""" One iteration of floor """
return _test_unary_elemwise(math_ops.floor, data)

#######################################################################
# Round
# -----

def _test_round(data):
""" One iteration of round """
return _test_unary_elemwise(math_ops.round, data)

#######################################################################
# Exp
# ---
Expand Down Expand Up @@ -787,6 +796,7 @@ def test_all_unary_elemwise():
if package_version.parse(tf.VERSION) >= package_version.parse('1.14.0'):
_test_forward_unary_elemwise(_test_ceil)
_test_forward_unary_elemwise(_test_cos)
_test_forward_unary_elemwise(_test_round)
_test_forward_unary_elemwise(_test_tan)
_test_forward_unary_elemwise(_test_elu)

Expand Down

0 comments on commit 5e7fbae

Please sign in to comment.