Skip to content

Commit

Permalink
TF frontend: add rint op (apache#6818)
Browse files Browse the repository at this point in the history
* TF frontend: add rint op

* Added negative numbers to the test
  • Loading branch information
alter-xp authored and Trevor Morris committed Dec 4, 2020
1 parent 7a13321 commit 0135dc1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,7 @@ def _impl(inputs, attr, params, mod):
"ResizeNearestNeighbor": _resize("nearest_neighbor"),
"ReverseV2": _reverse_v2(),
"RightShift": AttrCvt("right_shift"),
"Rint": AttrCvt("round"),
"Round": AttrCvt("round"),
"Rsqrt": _rsqrt(),
"Select": _where(),
Expand Down
17 changes: 17 additions & 0 deletions tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -3602,6 +3602,23 @@ def _test_forward_softsign(shape):
_test_forward_softsign([2, 5, 2, 5])


def test_forward_rint():
"""test operator rint """

def _test_forward_rint(shape):
tf.disable_eager_execution()
np_data = np.random.uniform(-100, 100, size=shape).astype(np.float32)
tf.reset_default_graph()
in_data = tf.placeholder(tf.float32, shape, name="in_data")
tf.math.rint(in_data, name="rint")
compare_tf_with_tvm([np_data], ["in_data:0"], "rint:0")

_test_forward_rint([100])
_test_forward_rint([1, 100])
_test_forward_rint([1, 10, 10])
_test_forward_rint([2, 5, 2, 5])


def test_forward_negative():
"""test tf operator Neg """
np_data = np.random.uniform(-100, 255, size=(224, 224, 3)).astype(np.float32)
Expand Down

0 comments on commit 0135dc1

Please sign in to comment.