You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ke...@apache.org on 2020/03/20 23:08:30 UTC
[incubator-tvm] branch master updated: [Relay][TF] Support for
Atan/Atan2 in Relay Tensorflow frontend converter. (#5104)
This is an automated email from the ASF dual-hosted git repository.
kevinthesun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/master by this push:
new a94f69f [Relay][TF] Support for Atan/Atan2 in Relay Tensorflow frontend converter. (#5104)
a94f69f is described below
commit a94f69fa0f655bd2da1dd3b1693224935c21a1fe
Author: Andrew Liu <an...@gmail.com>
AuthorDate: Fri Mar 20 16:08:22 2020 -0700
[Relay][TF] Support for Atan/Atan2 in Relay Tensorflow frontend converter. (#5104)
* add Atan/Atan2 op
* fix bug and testing
---
python/tvm/relay/frontend/tensorflow.py | 7 +++++++
tests/python/frontend/tensorflow/test_forward.py | 22 ++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/python/tvm/relay/frontend/tensorflow.py b/python/tvm/relay/frontend/tensorflow.py
index e0da863..ff69ccc 100644
--- a/python/tvm/relay/frontend/tensorflow.py
+++ b/python/tvm/relay/frontend/tensorflow.py
@@ -1535,6 +1535,11 @@ def _batch_to_space_nd():
return _impl
+def _atan2():
+ def _impl(inputs, attr, params):
+ divide = _elemwise("divide")(inputs, attr, params)
+ return get_relay_op("atan")(divide)
+ return _impl
def _prod():
def _impl(inputs, attr, params):
@@ -1615,6 +1620,8 @@ _convert_map = {
'ArgMax' : _argx(_op.argmax, 'argmax'),
'ArgMin' : _argx(_op.argmin, 'argmin'),
'Assert' : _assert(),
+ 'Atan' : AttrCvt('atan'),
+ 'Atan2' : _atan2(),
'AvgPool' : _pooling('avg_pool'),
'AvgPool3D' : _pool3d('avg_pool3d'),
'BatchMatMul' : _batch_matmul(),
diff --git a/tests/python/frontend/tensorflow/test_forward.py b/tests/python/frontend/tensorflow/test_forward.py
index a57d50c..2342606 100644
--- a/tests/python/frontend/tensorflow/test_forward.py
+++ b/tests/python/frontend/tensorflow/test_forward.py
@@ -2669,6 +2669,26 @@ def test_forward_tan():
tf.tan(in_data, name="tan")
compare_tf_with_tvm([np_data], ['in_data:0'], 'tan:0')
+def test_forward_atan():
+ """test operator tan """
+ tf.disable_eager_execution()
+ np_data = np.random.uniform(1, 100, size=(2, 3, 5)).astype(np.float32)
+ tf.reset_default_graph()
+ in_data = tf.placeholder(tf.float32, (2, 3, 5), name="in_data")
+ tf.atan(in_data, name="atan")
+ compare_tf_with_tvm([np_data], ['in_data:0'], 'atan:0')
+
+def test_forward_atan2():
+ """test operator tan """
+ tf.disable_eager_execution()
+ np_data_1 = np.random.uniform(1, 100, size=(2, 3, 5)).astype(np.float32)
+ np_data_2 = np.random.uniform(1, 100, size=(2, 3, 5)).astype(np.float32)
+ tf.reset_default_graph()
+ in_data_1 = tf.placeholder(tf.float32, (2, 3, 5), name="in_data_1")
+ in_data_2 = tf.placeholder(tf.float32, (2, 3, 5), name="in_data_2")
+ tf.atan2(in_data_1, in_data_2, name="atan2")
+ compare_tf_with_tvm([np_data_1, np_data_2], ['in_data_1:0', 'in_data_2:0'], 'atan2:0')
+
def test_forward_sin():
"""test operator sin """
@@ -3116,6 +3136,8 @@ if __name__ == '__main__':
test_forward_left_shift()
test_forward_truncatemod()
test_forward_one_hot()
+ test_forward_atan()
+ test_forward_atan2()
# Activations
test_forward_sigmoid()