Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay][Frontend] add log op in tf frontend #3111

Merged
merged 2 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Licensed to the Apache Software Foundation (ASF) under one
# Licensed to the Apache Software Foundation (ASF) under one
yongwww marked this conversation as resolved.
Show resolved Hide resolved
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
Expand Down Expand Up @@ -1093,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 @@ -1118,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 @@ -1150,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 @@ -1161,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