You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2020/08/21 00:02:28 UTC

[incubator-mxnet] branch master updated: fix #18927 (#18972)

This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 9bdd4d6  fix #18927 (#18972)
9bdd4d6 is described below

commit 9bdd4d6347c284770ee5bfe5ae98f1dabc283829
Author: Sheng Zha <sz...@users.noreply.github.com>
AuthorDate: Thu Aug 20 17:01:10 2020 -0700

    fix #18927 (#18972)
    
    * fix #18927
    
    * fix lint
---
 src/operator/contrib/bounding_box-inl.h |  5 +++++
 src/operator/contrib/bounding_box.cc    |  5 +++++
 tests/python/unittest/test_smoke.py     | 25 +++++++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/src/operator/contrib/bounding_box-inl.h b/src/operator/contrib/bounding_box-inl.h
index 010280e..93b79d0 100644
--- a/src/operator/contrib/bounding_box-inl.h
+++ b/src/operator/contrib/bounding_box-inl.h
@@ -728,6 +728,11 @@ void BipartiteMatchingForward(const nnvm::NodeAttrs& attrs,
   const BipartiteMatchingParam& param = nnvm::get<BipartiteMatchingParam>(attrs.parsed);
   Stream<xpu> *s = ctx.get_stream<xpu>();
   mxnet::TShape dshape = inputs[0].shape_;
+  CHECK(mxnet::shape_is_known(dshape)) << "Found unknown shape in BipartiteMatchingForward, "
+                                       << "received: " << dshape;
+  if (dshape.Size() == 0) {
+    return;  // noop for unknown shape or empty array
+  }
   int row = dshape[dshape.ndim() - 2];
   int col = dshape[dshape.ndim() - 1];
   int batch_size = dshape.Size() / row / col;
diff --git a/src/operator/contrib/bounding_box.cc b/src/operator/contrib/bounding_box.cc
index 906daa4..a0cc34b 100644
--- a/src/operator/contrib/bounding_box.cc
+++ b/src/operator/contrib/bounding_box.cc
@@ -37,6 +37,7 @@ DMLC_REGISTER_PARAMETER(BoxDecodeParam);
 
 NNVM_REGISTER_OP(_contrib_box_nms)
 .add_alias("_contrib_box_non_maximum_suppression")
+.add_alias("_npx_box_nms")
 .describe(R"code(Apply non-maximum suppression to input.
 
 The output will be sorted in descending order according to `score`. Boxes with
@@ -118,6 +119,7 @@ NNVM_REGISTER_OP(_backward_contrib_box_nms)
 .add_arguments(BoxNMSParam::__FIELDS__());
 
 NNVM_REGISTER_OP(_contrib_box_iou)
+.add_alias("_npx_box_iou")
 .describe(R"doc(Bounding box overlap of two arrays.
   The overlap is defined as Intersection-over-Union, aka, IOU.
   - lhs: (a_1, a_2, ..., a_n, 4) array
@@ -159,6 +161,7 @@ NNVM_REGISTER_OP(_backward_contrib_box_iou)
 .add_arguments(BoxOverlapParam::__FIELDS__());
 
 NNVM_REGISTER_OP(_contrib_bipartite_matching)
+.add_alias("_npx_bipartite_matching")
 .describe(R"doc(Compute bipartite matching.
   The matching is performed on score matrix with shape [B, N, M]
   - B: batch_size
@@ -206,6 +209,7 @@ NNVM_REGISTER_OP(_backward_contrib_bipartite_matching)
 .add_arguments(BipartiteMatchingParam::__FIELDS__());
 
 NNVM_REGISTER_OP(_contrib_box_encode)
+.add_alias("_npx_box_encode")
 .describe(R"doc(Encode bounding boxes training target with normalized center offsets.
     Input bounding boxes are using corner type: `x_{min}, y_{min}, x_{max}, y_{max}`.) array
 )doc" ADD_FILELINE)
@@ -228,6 +232,7 @@ NNVM_REGISTER_OP(_contrib_box_encode)
 .add_argument("stds", "NDArray-or-Symbol", "(4,) Std value to be divided from encoded values");
 
 NNVM_REGISTER_OP(_contrib_box_decode)
+.add_alias("_npx_box_decode")
 .describe(R"doc(Decode bounding boxes training target with normalized center offsets.
     Input bounding boxes are using corner type: `x_{min}, y_{min}, x_{max}, y_{max}`
     or center type: `x, y, width, height.) array
diff --git a/tests/python/unittest/test_smoke.py b/tests/python/unittest/test_smoke.py
new file mode 100644
index 0000000..6e64c8d
--- /dev/null
+++ b/tests/python/unittest/test_smoke.py
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from mxnet import np, npx, use_np
+from common import setup_module, teardown_module
+
+@use_np
+def test_18927():
+    """test for no error when dealing with zero-size array in bipartite matching"""
+    arr = np.random.rand(0,2)
+    npx.bipartite_matching(arr, threshold=0.1)