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] support elemwise logic ops #5361

Merged
merged 1 commit into from
Apr 24, 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
6 changes: 6 additions & 0 deletions python/tvm/relay/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,12 @@ def _get_bias_requantize_scale(_inputs, _data_scale, _kernel_scale):
"broadcast_greater_equal": _mx_compare(_op.greater_equal, _rename),
"broadcast_lesser" : _mx_compare(_op.less, _rename),
"broadcast_lesser_equal" : _mx_compare(_op.less_equal, _rename),
"_equal" : _mx_compare(_op.equal, _rename),
"_not_equal" : _mx_compare(_op.not_equal, _rename),
"_greater" : _mx_compare(_op.greater, _rename),
"_greater_equal" : _mx_compare(_op.greater_equal, _rename),
"_lesser" : _mx_compare(_op.less, _rename),
"_lesser_equal" : _mx_compare(_op.less_equal, _rename),
"elemwise_add" : _rename(_op.add),
"elemwise_sub" : _rename(_op.subtract),
"elemwise_mul" : _rename(_op.multiply),
Expand Down
12 changes: 9 additions & 3 deletions tests/python/frontend/mxnet/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,19 @@ def test_forward_broadcast_ops():

def test_forward_elemwise_ops():
for op in ["elemwise_add", "elemwise_sub", "elemwise_mul",
"elemwise_div", "maximum", "minimum"]:
"elemwise_div", "maximum", "minimum",
operator.lt, operator.le, operator.eq,
operator.ne, operator.gt, operator.ge]:
shape = (3, 4, 5)
dtype = 'float32'
a_np = np.random.uniform(size=shape).astype(dtype)
b_np = np.random.uniform(size=shape).astype(dtype)
mx_sym = _mx_symbol(mx.sym, op, [mx.sym.var('a'), mx.sym.var('b')])
ref_res = _mx_symbol(mx.nd, op, [mx.nd.array(a_np), mx.nd.array(b_np)])
if type(op) == str:
mx_sym = _mx_symbol(mx.sym, op, [mx.sym.var('a'), mx.sym.var('b')])
ref_res = _mx_symbol(mx.nd, op, [mx.nd.array(a_np), mx.nd.array(b_np)])
else:
mx_sym = op(mx.sym.var('a'), mx.sym.var('b'))
ref_res = op(mx.nd.array(a_np), mx.nd.array(b_np))
shapes = {'a': shape, 'b': shape}
mod, _ = relay.frontend.from_mxnet(mx_sym, shapes, dtype)
for target, ctx in ctx_list():
Expand Down