From 426e048dfa1a19ffc454bb96a61067eb7550cbb1 Mon Sep 17 00:00:00 2001 From: Insop Song Date: Sat, 2 Jan 2021 21:31:54 -0800 Subject: [PATCH 1/2] [Frontend][MXNet] add _npi_subtract_scalar - add mxnet numpy operator, subtract - https://github.com/apache/tvm/issues/7186 - https://mxnet.apache.org/versions/master/api/python/docs/api/np/generated/mxnet.np.subtract.html --- python/tvm/relay/frontend/mxnet.py | 2 ++ tests/python/frontend/mxnet/test_forward.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/python/tvm/relay/frontend/mxnet.py b/python/tvm/relay/frontend/mxnet.py index f2330c72e1f4..1085e904c386 100644 --- a/python/tvm/relay/frontend/mxnet.py +++ b/python/tvm/relay/frontend/mxnet.py @@ -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), diff --git a/tests/python/frontend/mxnet/test_forward.py b/tests/python/frontend/mxnet/test_forward.py index f076a27755ad..06ff05e64e6e 100644 --- a/tests/python/frontend/mxnet/test_forward.py +++ b/tests/python/frontend/mxnet/test_forward.py @@ -1983,7 +1983,6 @@ def test_forward_npi_transpose(data_shape, axes, dtype, target, ctx, kind): op_res = intrp.evaluate()(data_np) tvm.testing.assert_allclose(op_res.asnumpy(), ref_res.asnumpy(), rtol=1e-5) - @pytest.mark.parametrize( "data_shape1, data_shape2, axis", [ @@ -2062,8 +2061,10 @@ 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] @@ -2092,8 +2093,10 @@ 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] From f186ac2bf589d1e4b689b44ffa339fe3ad201052 Mon Sep 17 00:00:00 2001 From: Insop Song Date: Sat, 2 Jan 2021 21:38:14 -0800 Subject: [PATCH 2/2] Fix python style using black --- 3rdparty/vta-hw | 2 +- tests/python/frontend/mxnet/test_forward.py | 25 ++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/3rdparty/vta-hw b/3rdparty/vta-hw index 57db5a718c74..87ce9acfae55 160000 --- a/3rdparty/vta-hw +++ b/3rdparty/vta-hw @@ -1 +1 @@ -Subproject commit 57db5a718c74a788c98120ebbe1230797be698c8 +Subproject commit 87ce9acfae550d1a487746e9d06c2e250076e54c diff --git a/tests/python/frontend/mxnet/test_forward.py b/tests/python/frontend/mxnet/test_forward.py index 06ff05e64e6e..d3be8c0506ba 100644 --- a/tests/python/frontend/mxnet/test_forward.py +++ b/tests/python/frontend/mxnet/test_forward.py @@ -1983,6 +1983,7 @@ def test_forward_npi_transpose(data_shape, axes, dtype, target, ctx, kind): op_res = intrp.evaluate()(data_np) tvm.testing.assert_allclose(op_res.asnumpy(), ref_res.asnumpy(), rtol=1e-5) + @pytest.mark.parametrize( "data_shape1, data_shape2, axis", [ @@ -2061,10 +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.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] + 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] @@ -2093,10 +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.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] + 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]