Skip to content

Commit

Permalink
[Relay][Frontend] add log op in tf frontend (#3111)
Browse files Browse the repository at this point in the history
* [Relay][Frontend] add log op in tf frontend

* address comment
  • Loading branch information
yongwww authored and yzhliu committed May 5, 2019
1 parent 88daa2b commit 094fc68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ def _impl(inputs, attr, params):
'ArgMin' : _argx(_op.argmin, 'argmin'),
'AvgPool' : _pooling('avg_pool'),
'BatchNormWithGlobalNormalization' : _batch_norm(),
'BatchToSpaceND' : _batch_to_space_nd(),
'BiasAdd' : _bias_add(),
'Cast' : _cast(),
'Ceil' : AttrCvt('ceil'),
Expand All @@ -1119,6 +1120,7 @@ def _impl(inputs, attr, params):
'LeakyRelu' : AttrCvt('leaky_relu'),
'Less' : _broadcast('less'),
'LessEqual' : _broadcast('less_equal'),
'Log' : AttrCvt('log'),
'LogicalAnd' : _logical('logical_and'),
'LogicalOr' : _logical('logical_or'),
'LogicalNot' : _logical('logical_not'),
Expand Down Expand Up @@ -1151,6 +1153,7 @@ def _impl(inputs, attr, params):
'Sign' : AttrCvt('sign'),
'Slice' : _slice(),
'Softmax' : _softmax(),
'SpaceToBatchND' : _space_to_batch_nd(),
'Split' : _split(False),
'SplitV' : _split(True),
'Square' : _square(),
Expand All @@ -1162,8 +1165,7 @@ def _impl(inputs, attr, params):
'Tile' : _tile(),
'Transpose' : _transpose(),
'Unpack' : _unpack(),
'SpaceToBatchND' : _space_to_batch_nd(),
'BatchToSpaceND' : _batch_to_space_nd(),

}

def _LSTMBlockCell():
Expand Down
19 changes: 19 additions & 0 deletions tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,23 @@ def test_forward_pow_exp():
compare_tf_with_tvm([np_in1, np_in2], ['in1:0', 'in2:0'], 'pow:0')
compare_tf_with_tvm([np_in1], ['in1:0'], 'exp:0')

def test_forward_log():
"""test Log """
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.log(in_data, name="log")
compare_tf_with_tvm([np_data], ['in_data:0'], 'log:0')

def test_forward_rsqrt():
"""test Rsqrt """
np_data = np.random.uniform(1, 100, size=(5, 7, 11)).astype(np.float32)
tf.reset_default_graph()
in_data = tf.placeholder(tf.float32, (5, 7, 11), name="in_data")
tf.rsqrt(in_data, name="rsqrt")
print(tf.get_default_graph().as_graph_def())
compare_tf_with_tvm([np_data], ['in_data:0'], 'rsqrt:0')

#######################################################################
# Mean
# ----
Expand Down Expand Up @@ -1525,6 +1542,8 @@ def test_forward_expand_dims():
test_forward_reverse_v2()
test_forward_pow_exp()
test_forward_sign()
test_forward_log()
test_forward_rsqrt()
test_forward_expand_dims()

# Reductions
Expand Down

0 comments on commit 094fc68

Please sign in to comment.