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

[FRONTEND][MXNET]abs, round, reciprocal, sign, softsign, hard_sigmoid ops support #5587

Merged
merged 1 commit into from
May 13, 2020
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
19 changes: 19 additions & 0 deletions python/tvm/relay/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,19 @@ def _mx_l2_normalize(inputs, attrs):
return _op.nn.l2_normalize(inputs[0], **new_attrs)


def _mx_softsign(inputs, attrs):
return inputs[0] / (_expr.const(1.0) + _op.abs(inputs[0]))


def _mx_hard_sigmoid(inputs, attrs):
x = (_expr.const(0.2) * inputs[0]) + _expr.const(0.5)
return _op.clip(x, a_min=0.0, a_max=1.0)


def _mx_reciprocal(inputs, attrs):
return _expr.const(1.0) /inputs[0]


def _mx_shape_array(inputs, attrs):
assert len(inputs) == 1
if attrs.get_int("lhs_begin", None) is not None:
Expand Down Expand Up @@ -1742,12 +1755,15 @@ def impl(inputs, input_types):
# Note: due to attribute conversion constraint
# ops in the identity set must be attribute free
_identity_list = [
"abs",
"log",
"exp",
"erf",
"sqrt",
"floor",
"ceil",
"round",
"sign",
"sigmoid",
"negative",
"reshape_like",
Expand Down Expand Up @@ -1856,6 +1872,9 @@ def impl(inputs, input_types):
"softmax" : _softmax_op(_op.nn.softmax),
"log_softmax" : _softmax_op(_op.nn.log_softmax),
"Softmax" : _softmax_op(_op.nn.softmax),
"softsign" : _mx_softsign,
"hard_sigmoid" : _mx_hard_sigmoid,
"reciprocal" : _mx_reciprocal,
# per op specialization
"Reshape" : _reshape,
"reshape" : _reshape,
Expand Down
4 changes: 3 additions & 1 deletion tests/python/frontend/mxnet/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ def test_forward_elemwise_ops():


def test_forward_unary_ops():
for op in ["cos", "sin", "tan",
for op in ["abs", "sqrt", "ceil", "floor", "round", "reciprocal",
"softsign", "hard_sigmoid",
"cos", "sin", "tan",
"cosh", "sinh", "tanh",
"arccos", "arcsin", "arctan",
"arccosh", "arcsinh", "arctanh"]:
Expand Down