Skip to content

Commit 094fc68

Browse files
yongwwwyzhliu
authored andcommitted
[Relay][Frontend] add log op in tf frontend (#3111)
* [Relay][Frontend] add log op in tf frontend * address comment
1 parent 88daa2b commit 094fc68

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

python/tvm/relay/frontend/tensorflow.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ def _impl(inputs, attr, params):
10941094
'ArgMin' : _argx(_op.argmin, 'argmin'),
10951095
'AvgPool' : _pooling('avg_pool'),
10961096
'BatchNormWithGlobalNormalization' : _batch_norm(),
1097+
'BatchToSpaceND' : _batch_to_space_nd(),
10971098
'BiasAdd' : _bias_add(),
10981099
'Cast' : _cast(),
10991100
'Ceil' : AttrCvt('ceil'),
@@ -1119,6 +1120,7 @@ def _impl(inputs, attr, params):
11191120
'LeakyRelu' : AttrCvt('leaky_relu'),
11201121
'Less' : _broadcast('less'),
11211122
'LessEqual' : _broadcast('less_equal'),
1123+
'Log' : AttrCvt('log'),
11221124
'LogicalAnd' : _logical('logical_and'),
11231125
'LogicalOr' : _logical('logical_or'),
11241126
'LogicalNot' : _logical('logical_not'),
@@ -1151,6 +1153,7 @@ def _impl(inputs, attr, params):
11511153
'Sign' : AttrCvt('sign'),
11521154
'Slice' : _slice(),
11531155
'Softmax' : _softmax(),
1156+
'SpaceToBatchND' : _space_to_batch_nd(),
11541157
'Split' : _split(False),
11551158
'SplitV' : _split(True),
11561159
'Square' : _square(),
@@ -1162,8 +1165,7 @@ def _impl(inputs, attr, params):
11621165
'Tile' : _tile(),
11631166
'Transpose' : _transpose(),
11641167
'Unpack' : _unpack(),
1165-
'SpaceToBatchND' : _space_to_batch_nd(),
1166-
'BatchToSpaceND' : _batch_to_space_nd(),
1168+
11671169
}
11681170

11691171
def _LSTMBlockCell():

tests/python/frontend/tensorflow/test_forward.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,23 @@ def test_forward_pow_exp():
14401440
compare_tf_with_tvm([np_in1, np_in2], ['in1:0', 'in2:0'], 'pow:0')
14411441
compare_tf_with_tvm([np_in1], ['in1:0'], 'exp:0')
14421442

1443+
def test_forward_log():
1444+
"""test Log """
1445+
np_data = np.random.uniform(1, 100, size=(2, 3, 5)).astype(np.float32)
1446+
tf.reset_default_graph()
1447+
in_data = tf.placeholder(tf.float32, (2, 3, 5), name="in_data")
1448+
tf.log(in_data, name="log")
1449+
compare_tf_with_tvm([np_data], ['in_data:0'], 'log:0')
1450+
1451+
def test_forward_rsqrt():
1452+
"""test Rsqrt """
1453+
np_data = np.random.uniform(1, 100, size=(5, 7, 11)).astype(np.float32)
1454+
tf.reset_default_graph()
1455+
in_data = tf.placeholder(tf.float32, (5, 7, 11), name="in_data")
1456+
tf.rsqrt(in_data, name="rsqrt")
1457+
print(tf.get_default_graph().as_graph_def())
1458+
compare_tf_with_tvm([np_data], ['in_data:0'], 'rsqrt:0')
1459+
14431460
#######################################################################
14441461
# Mean
14451462
# ----
@@ -1525,6 +1542,8 @@ def test_forward_expand_dims():
15251542
test_forward_reverse_v2()
15261543
test_forward_pow_exp()
15271544
test_forward_sign()
1545+
test_forward_log()
1546+
test_forward_rsqrt()
15281547
test_forward_expand_dims()
15291548

15301549
# Reductions

0 commit comments

Comments
 (0)