You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/01/07 16:38:48 UTC

[GitHub] [incubator-tvm] inadob commented on a change in pull request #4634: [Relay][Frontend][TFlite] Add parses support for unary elemwise ops

inadob commented on a change in pull request #4634: [Relay][Frontend][TFlite] Add parses support for unary elemwise ops
URL: https://github.com/apache/incubator-tvm/pull/4634#discussion_r363838587
 
 

 ##########
 File path: tests/python/frontend/tflite/test_forward.py
 ##########
 @@ -616,6 +616,109 @@ def test_forward_concatenation():
          np.arange(6).reshape((2, 1, 1, 3)),
          np.arange(6).reshape((2, 1, 1, 3))], 1)
 
+#######################################################################
+# Unary elemwise
+# --------------
+
+def _test_unary_elemwise(math_op, data):
+    """ One iteration of unary elemwise """
+
+    with tf.Graph().as_default():
+        in_data = array_ops.placeholder(shape=data.shape, dtype=data.dtype, name='in')
+        out = math_op(in_data)
+        compare_tflite_with_tvm(data, ['in:0'], in_data, [out])
+
+#######################################################################
+# Abs
+# ---
+
+def _test_abs(data):
+    """ One iteration of abs """
+    return _test_unary_elemwise(math_ops.abs, data)
+#######################################################################
+# Ceil
+# ----
+
+def _test_ceil(data):
+    """ One iteration of ceil """
+    return _test_unary_elemwise(math_ops.ceil, data)
+#######################################################################
+# Floor
+# -----
+
+def _test_floor(data):
+    """ One iteration of floor """
+    return _test_unary_elemwise(math_ops.floor, data)
+#######################################################################
+# Exp
+# ---
+
+def _test_exp(data):
+    """ One iteration of exp """
+    return _test_unary_elemwise(math_ops.exp, data)
+#######################################################################
+# Log
+# ---
+
+def _test_log(data):
+    """ One iteration of log """
+    return _test_unary_elemwise(math_ops.log, data)
+#######################################################################
+# Sin
+# ---
+
+def _test_sin(data):
+    """ One iteration of sin """
+    return _test_unary_elemwise(math_ops.sin, data)
+#######################################################################
+# Cos
+# ---
+
+def _test_cos(data):
+    """ One iteration of cos """
+    return _test_unary_elemwise(math_ops.cos, data)
+#######################################################################
+# Sqrt
+# ----
+
+def _test_sqrt(data):
+    """ One iteration of sqrt """
+    return _test_unary_elemwise(math_ops.sqrt, data)
+#######################################################################
+# Rsqrt
+# -----
+
+def _test_rsqrt(data):
+    """ One iteration of rsqrt """
+    return _test_unary_elemwise(math_ops.rsqrt, data)
+#######################################################################
+# Neg
+# ---
+
+def _test_neg(data):
+    """ One iteration of neg """
+    return _test_unary_elemwise(math_ops.neg, data)
+#######################################################################
+
+def _test_forward_unary_elemwise(testop):
 
 Review comment:
   That's how the binary elementwise operators were implemented. Do you want me to change both?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services