Skip to content

Commit

Permalink
[Frontend][MXNet] add _npi_subtract_scalar (apache#7191)
Browse files Browse the repository at this point in the history
* [Frontend][MXNet] add _npi_subtract_scalar

- add mxnet numpy operator, subtract
- apache#7186
- https://mxnet.apache.org/versions/master/api/python/docs/api/np/generated/mxnet.np.subtract.html

* Fix python style using black
  • Loading branch information
insop authored and Tushar Dey committed Jan 20, 2021
1 parent af57510 commit 160c97d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/vta-hw
2 changes: 2 additions & 0 deletions python/tvm/relay/frontend/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2693,6 +2693,8 @@ def _mx_npi_where_rscalar(inputs, attrs):
"_npi_multiply_scalar": _binop_scalar(_op.multiply),
"_npi_add": _rename(_op.add),
"_npi_add_scalar": _binop_scalar(_op.add),
"_npi_subtract": _rename(_op.subtract),
"_npi_subtract_scalar": _binop_scalar(_op.subtract),
"_npi_where_rscalar": _mx_npi_where_rscalar,
"_npi_less": _rename(_op.less),
"_npi_less_equal": _mx_compare(_op.less_equal, _rename),
Expand Down
20 changes: 16 additions & 4 deletions tests/python/frontend/mxnet/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2062,8 +2062,14 @@ def test_forward_npx_reshape(data_shape, out_shape, dtype, target, reverse, ctx,
@tvm.testing.parametrize_targets
@pytest.mark.parametrize("kind", ["graph", "vm", "debug"])
def test_forward_npi_binary(data_shape, dtype, target, ctx, kind):
ref_ops = [mx.np.power, mx.np.multiply, mx.np.add, mx.np.less]
mx_ops = [mx.sym.np.power, mx.sym.np.multiply, mx.sym.np.add, mx.sym.np.less]
ref_ops = [mx.np.power, mx.np.multiply, mx.np.add, mx.np.subtract, mx.np.less]
mx_ops = [
mx.sym.np.power,
mx.sym.np.multiply,
mx.sym.np.add,
mx.sym.np.subtract,
mx.sym.np.less,
]
for i in range(len(ref_ops)):
ref_op = ref_ops[i]
mx_op = mx_ops[i]
Expand Down Expand Up @@ -2092,8 +2098,14 @@ def test_forward_npi_binary(data_shape, dtype, target, ctx, kind):
@pytest.mark.parametrize("scalar", [1.0, 2.0, 3.0, 4.0])
@pytest.mark.parametrize("kind", ["graph", "vm", "debug"])
def test_forward_npi_binary_scalar(data_shape, dtype, scalar, target, ctx, kind):
ref_ops = [mx.np.power, mx.np.multiply, mx.np.add, mx.np.true_divide]
mx_ops = [mx.sym.np.power, mx.sym.np.multiply, mx.sym.np.add, mx.sym.np.true_divide]
ref_ops = [mx.np.power, mx.np.multiply, mx.np.add, mx.np.subtract, mx.np.true_divide]
mx_ops = [
mx.sym.np.power,
mx.sym.np.multiply,
mx.sym.np.add,
mx.sym.np.subtract,
mx.sym.np.true_divide,
]
for i in range(len(ref_ops)):
ref_op = ref_ops[i]
mx_op = mx_ops[i]
Expand Down

0 comments on commit 160c97d

Please sign in to comment.