Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions python/tvm/relay/frontend/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,15 @@ def _impl(inputs, attr, params, mod):
return _impl


def _expm1():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the docstring describing what this operation is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I added TF description address

# op description: https://www.tensorflow.org/api_docs/python/tf/math/expm1
def _impl(inputs, attr, params, mod):
exp_out = get_relay_op("exp")(inputs[0])
return exp_out - tvm.relay.const(1.0)

return _impl


def _resize(method):
def _impl(inputs, attr, params, mod):
if attr["_output_shapes"][0] is not None:
Expand Down Expand Up @@ -2297,6 +2306,7 @@ def _impl(inputs, attr, params, mod):
"EuclideanNorm": _euclidean_norm(),
"Exp": AttrCvt("exp"),
"ExpandDims": _expand_dims(),
"Expm1": _expm1(),
"Fill": _fill(),
"Floor": AttrCvt("floor"),
"FloorDiv": _floordiv(),
Expand Down
16 changes: 16 additions & 0 deletions tests/python/frontend/tensorflow/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -3488,6 +3488,22 @@ def test_forward_atan2():
compare_tf_with_tvm([np_data_1, np_data_2], ["in_data_1:0", "in_data_2:0"], "atan2:0")


def test_forward_expm1():
"""test operator expm1 """

def _test_forward_expm1(shape):
tf.disable_eager_execution()
np_data = np.random.uniform(1, 10, size=shape).astype(np.float32)
tf.reset_default_graph()
in_data = tf.placeholder(tf.float32, shape, name="in_data")
tf.expm1(in_data, name="expm1")
compare_tf_with_tvm([np_data], ["in_data:0"], "expm1:0")

_test_forward_expm1([1, 100])
_test_forward_expm1([1, 10, 10])
_test_forward_expm1([2, 5, 2, 5])


def test_forward_negative():
"""test tf operator Neg """
np_data = np.random.uniform(-100, 255, size=(224, 224, 3)).astype(np.float32)
Expand Down